Difference Between Float and Double in Java

Both float and double data types represent floating point numbers in Java. The float data type is a single-precision 32-bit IEEE 754 floating point...
Java Equals Hashcode

Equals and Hashcode Methods in Java

Many Java classes including collection classes (like HashMap, HashTable, HashSet) use hashCode() and equals() methods to compare objects. If two objects are equal, they should...
Java Immutable Object

Immutable Objects in Java

Immutable objects are objects that cannot be changed once created. For instance, String is an immutable class in Java. Consider the code below, in the first...
Java Inheritance

Java Inheritance and Composition

Inheritance and composition are the two common methods to reuse code in Java. Inheritance is also known as "IS-A Relationship", composition is known as...

Checked/Unchecked Exceptions

There are two types of exceptions in Java: Checked Exceptions, Unchecked Exceptions Any exception extended from Error or RuntimeException is an Unchecked Exception. Any exception extended...
Java Finalize Method

Java Finalize Method

Garbage Collector (GC) reclaims memory occupied by objects that are no longer in use by the program. GC calls object's finalize() method to perform...