Equals() method is defined in Object class in Java and used for checking equality of two objects defined by business logic.
“==” or equality operator in Java is a binary operator provided by Java programming language and used to compare primitives and objects. public boolean equals(Object o) is the method provided by the Object class. The default implementation uses == operator to compare two objects. For example: method can be overridden like String class. equals() method is used to compare the values of two objects.
Feature | Stack | Heap |
---|---|---|
Memory | Stack memory is used only by one thread of execution. | Heap memory is used by all the parts of the application. |
Access | Stack memory can’t be accessed by other threads. | Objects stored in the heap are globally accessible. |
Memory Management | Follows LIFO manner to free memory. | Memory management is based on the generation associated with each object. |
Lifetime | Exists until the end of execution of the thread. | Heap memory lives from the start till the end of application execution. |
Usage | Stack memory only contains local primitive and reference variables to objects in heap space. | Whenever an object is created, it’s always stored in the Heap space. |
The Java ClassLoader is a subset of JVM (Java Virtual Machine) that is responsible for loading the class files. Whenever a Java program is executed it is first loaded by the classloader. Java provides three built-in classloaders: