Methods defined by Object class in java.lang

Here are the methods defined by Object class in java.lang:

equals( ) method: It is used to check whether two objects are equal. It returns true if objects are equal, otherwise false.


boolean equals(Object ob)

finalize( ) method: It is called before recycling an unused object.


void finalize( ) throws Throwable

getClass( ) method: It is used to get a class object.


final Class getClass( )

notify( ) and notifyAll( ) methods: Both are used to resumes execution of a thread.


final void notify( )

final void notifyAll( )

toString( ) method: It is used to find the string equivalent of a calling object.


String toString( )

wait method: It is used to notify a thread to go to sleep.


final void wait( ) throws InterruptedException

In milliseconds:

final void wait(long milliseconds) throws InterruptedException

In nanoseconds:

final void wait(long milliseconds, int nanoseconds) throws InterruptedException

clone( ) method: It is used to create a new object same as calling object.


Object clone( ) throws CloneNotSupportedException

Leave a Reply