Java Object Class
Java Object class is the root class from which all other classes inherit directly or indirectly. It is a fundamental part of Java’s object-oriented structure and provides a set of methods available to every Java object.
Object methods
Object Class is the root of the class hierarchy. Every class has an Object as a superclass. All objects,
including arrays, implement the methods of this class. The Object class defines the basic state and behavior that all objects must have. The Object class methods are as follows:
Method | Description |
Object clone() | Creates and returns a copy of this object. The precise meaning of “copy” may depend on the object’s class. |
Class<?> getClass() | Returns the runtime class of this Object. The returned Class object is the object that is locked by static synchronized methods of the represented class. |
int hashCode() | Returns a hash code value for the object. This method is supported to benefit hash tables such as those provided by java.util.HashMap. |
boolean equals(Object obj) | Indicates whether some other object is “equal to” this one. |
String toString() | Returns a string representation of the object. |
Example
In the above example, the class declaration is the same as:
public class Program extends Object {
Java Tutorials
Java Tutorial on this website:
For more information on Java, visit the official website :