Garbage collection is the process of reclaiming the used memory which is no more reference objects in the application. Java Virtual Machine (JVM) runs the background thread for monitoring the object references and runs periodically to claim the memory. This thread runs on the low priority since the performance of JVM will be impacted while running …
NullPointerException in Java
One of the most common and nightmare for the Java programmers are getting the NullPointerException while running the Java application. This exception is defined at the “java.lang” package and the purpose of the exception is to detect if an object is used without any content. Here you must understand the difference between Reference and Object. …
java.util.ConcurrentModificationException
ConcurrentModificationException is thrown when two threads are updating the same element on same time. This issue occurs often in the multithreaded environment. However, this also can occur in the single thread environment where same application running the multiple threads which updates the same object. Look at this example which throws ConcurrentModificationException while updating the value …
How To Get JVM Start Time And Date
This example shows how to get the start time and date for the current execution environment of Java Virtual Machine (JVM). RuntimeMXBean in the Java lang package helps in getting the details of the JVM start time. By invoking the method getStartTime() in RuntimeMXBean class, it returns the time in long number which can be …
Format Number with NumberFormat
NumberFormat is the abstract parent class for all the number formats. This class provides methods for formatting and parsing the numbers. Also it provides methods for finding locales for the number formats. It has the direct subclasses: ChoiceFormat and DecimalFormat Look at the below example for the different number formats. Here I have used the …
Continue Statement in Java
This example shows how to use the continue statement in Java programming. In my previous example I have explained about the break statement which is useful for termination the look and come out of it. However, in certain cases one might want to terminate only the current iteration and skip to the next iteration. In that …
Break Statement in Java
This example shows how to use the break statement in Java programming. Break itself a keyword that can be used within a block like for, while, do-while or switch statements. The significance of the break statement is to terminate the current loop and exit the block. It is mostly useful in the loops while we …
Java Dictionary Example
Dictionary class is the abstract class which is parent of any class which uses the key and value pair relationship. The classes like HashTable extends this class for their functionality. Every key and every value is an object. In any one Dictionary object, every key is associated with at most one value. As a rule, the equals method should be used …