Object class in Java
Object is the base class for all other objects in Java. Any class inherits from Object and, accordingly, inherits its methods:
- public boolean equals(Object obj) - is used to compare objects by value;
- int hashCode() - returns the hash code for the object;
- String toString() - returns the string representation of the object;
- Class getClass() - returns the class of the object at runtime;
- protected Object clone() - creates and returns a copy of the object;
- void notify() - resumes the thread waiting for the monitor;
- void notifyAll() - resumes all threads waiting on the monitor;
- void wait() - stopping the thread that called the method until another thread calls the notify() or notifyAll() method for this object;
- void wait(long timeout) - stopping the thread that called the method for a certain time or until another thread calls the notify() or notifyAll() method for this object;
- void wait(long timeout, int nanos) - stopping the thread that called the method for a certain time or until another thread calls the notify() or notifyAll() method for this object;
- protected void finalize() - can be called by the garbage collector when the object is removed by garbage collection.
Read also:
- Type casting in Java
- Autoboxing in Java and rules for wrapping primitive types in wrapper classes
- Class String in Java
Comments
Post a Comment