Raja has Published 771 Articles

What is a LayoutManager and types of LayoutManager in Java?

raja

raja

Updated on 19-Feb-2024 04:20:24

27K+ Views

The Layout managers enable us to control the way in which visual components are arranged in the GUI forms by determining the size and position of components within the containers. Types of LayoutManager There are 6 layout managers in Java FlowLayout: It arranges the components in a ... Read More

How can we initialize a boolean array in Java?

raja

raja

Updated on 01-Dec-2023 15:03:32

21K+ Views

The boolean array can be used to store boolean datatype values only and the default value of the boolean array is false. An array of booleans are initialized to false and arrays of reference types are initialized to null. In some cases, we need to initialize all values of the ... Read More

How can we use the StringTokenizer class in Java?

raja

raja

Updated on 01-Dec-2023 14:52:22

115 Views

A StringTokenizer is a subclass of Object class and it can allow an application to break a string into tokens. A set of delimiters can be specified either at creation time or on a per-token basis. An instance of StringTokenizer behaves in two ways depending on whether it was created ... Read More

How to save the elements of a TreeSet to a file in Java?

raja

raja

Updated on 01-Dec-2023 14:47:10

309 Views

A TreeSet is a subclass of AbstractSet class and it does not allow duplicate elements. By default, TreeSet stores the elements in an ascending order and retrieval speed of an element out of a TreeSet is faster. The TreeSet class internally uses a TreeMap to store elements. The elements in ... Read More

When can we use the getClass() method in Java?

raja

raja

Updated on 01-Dec-2023 14:43:00

117 Views

The getClass() method is from Object class and it returns an instance of the Class class. When we declare a new instance of an object, it will be referring to a class. There can only be one class per JVM but multiple object referring to it. So when we get ... Read More

What is the purpose of using a dumpStack() method in Java?

raja

raja

Updated on 01-Dec-2023 14:39:39

464 Views

The dumpStack() method is a static method of Thread class and it can be used to print or display stack tracing of the current thread to System.err. The purpose of the dumpStack() method is basically for debugging and Internally this method is calling the printStackTrace() method of Throwable class. This ... Read More

How to check if the string begins with specific substring in Java?

raja

raja

Updated on 01-Dec-2023 14:34:36

1K+ Views

A String class can be used to represent the character strings, all the string literals in a Java program are implemented as an instance of a String class. The Strings are constants and their values cannot be changed (immutable) once created. We can use the startsWith() method of String class to ... Read More

Can we override a protected method in Java?

raja

raja

Updated on 01-Dec-2023 11:07:06

5K+ Views

Yes, the protected method of a superclass can be overridden by a subclass. If the superclass method is protected, the subclass overridden method can have protected or public (but not default or private) which means the subclass overridden method can not have a weaker access specifier. Example class A { ... Read More

How to check if the string ends with specific substring in Java?

raja

raja

Updated on 01-Dec-2023 11:01:53

854 Views

A String is an object that represents an immutable sequence of characters and cannot be changed once created. The java.lang.String class can be used to create a string object. We can use the endsWith() method of String class to check whether a string ends with a specific string or not, it ... Read More

When can a double-type be preferred over float-type in Java?

raja

raja

Updated on 01-Dec-2023 10:53:42

179 Views

Both double-type and float-type can be used to represent floating-point numbers in Java. A double-type is preferred over float-type if the more precise and accurate result is required. The precision of double-type is up to 15 to 16 decimal points while the precision of float type is only around 6 ... Read More

1 2 3 4 5 ... 78 Next
Advertisements