Java 7 New Feature Writing same logic in every catch block is very tedious job and it also not good for readability of the Java program. In Java SE 7 and later, a single catch block can handle more than one type of exception. This feature can reduce code duplication and lessen the temptation to…
HashMap Load Factor and Initial Capacity
Initial Capacity and Load Factor in HashMap are two parameters that affect its performance. Initial Capacity In HashMap The capacity is the number of buckets in the hash table, and the initial capacity is simply the capacity at the time the hash table is created. Default initial capacity is 16. Load factor In HashMap The…
Need Of serialVersionUID In Serialization
serialVersionUID In Serialization If we do not explicitly declare serialVersionUID during serialization then JVM generates this ID based upon the structure of class. And then if we implement another interface or any other class or change the structure of class then JVM will generate different serialVersionUID for the class. After that if we try to…
Singleton In Java
Singleton in java is a class which has only one instance in whole application and provides a getInstance() method to access the singleton instance. There are many classes in JDK which is implemented using Singleton pattern like java.lang.Runtime which provides getRuntime() method to get access of it. There are many ways to create singleton in…