Java Object Class
In java, the Object class is the super most class of any class hierarchy. The Object class in the java programming language is present inside the java.lang package.
Every class in the java programming language is a subclass of Object class by default.
The Object class is useful when you want to refer to any object whose type you don't know. Because it is the superclass of all other classes in java, it can refer to any type of object.
Methods of Object class
The following table depicts all built-in methods of Object class in java.
Method | Description | Return Value |
---|---|---|
getClass() | Returns Class class object | object |
hashCode() | returns the hashcode number for object being used. | int |
equals(Object obj) | compares the argument object to calling object. | boolean |
clone() | Compares two strings, ignoring case | int |
concat(String) | Creates copy of invoking object | object |
toString() | eturns the string representation of invoking object. | String |
notify() | wakes up a thread, waiting on invoking object's monitor. | void |
notifyAll() | wakes up all the threads, waiting on invoking object's monitor. | void |
wait() | causes the current thread to wait, until another thread notifies. | void |
wait(long,int) | causes the current thread to wait for the specified milliseconds and nanoseconds, until another thread notifies. | void |
finalize() | It is invoked by the garbage collector before an object is being garbage collected. | void |