java.lang.Object
Class Object 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.
Every class in Java is directly or indirectly derived from the Object class. If a class does not extend any other class then it is a direct child class of Object and if extends another class then it is indirectly derived. Therefore the Object class methods are available to all Java classes.
In other words, we can say the Object class acts as a root of the inheritance hierarchy in any Java Program.
Some methods of Object class
equals(): This method indicates whether some other object is "equal to" this one.
hashCode(): This method returns a hash code value for the object.
getClass(): The returned Class object is the object that is locked by static synchronized methods of the represented class.
toString(): This method returns a string representation of the object.
No comments:
Post a Comment