Java Object Class methods

The Object class is in rt.jar package, and it is a super class of all classes in java either user defined or pre-defined classes. It provides some default methods which is available in all classes by default.

Object classes methods
toString() It is used to convert any object to String.
hashCode() It returns unique integers for each and every objects.
public boolean equals(Object obj) It compares the given object values with the “this” object.
public final Class getClass() It is final method, However it returns the class object.
protected void finalize() throws Throwable Finalize() method runs last and known that garbage collection has completed its task.
protected Object clone() throws CloneNotSupportedException It provides the same exact new object as this object.
public final void notify() It wakes up single thread waiting for the object.
public final void notifyAll() It wakes up all threads waiting for the object.
public final void wait(long timeout) throws interruptedException It will wait the current thread for the specified milliseconds, until another thread notifies.
public final void wait(long timeout, int nanos) throws interruptedException It will wait the current thread for the specified milliseconds and nano seconds, until another thread notifies.
public final void wait() throws interruptedException It will wait the current thread, until another thread notifies.
PREVIOUS PAGE NEXT PAGE
Facebooktwittergoogle_plusredditpinterestlinkedinmail
1 Star2 Stars3 Stars4 Stars5 Stars (13 votes, average: 4.85 out of 5)
Loading...