The standard class Object is a superclass (§8.1) of all other classes. A variable of
type Object can hold a reference to any object, whether it is an instance of a class
or an array (§10). All class and array types inherit the methods of class Object,
which are summarized here and completely specified in §20.1:
package java.lang;
public class Object {
public final Class getClass() { . . . }
public String toString() { . . . }
public boolean equals(Object obj) { . . . }
public int hashCode() { . . . }
protected Object clone()
throws CloneNotSupportedException { . . . }
public final void wait()
throws IllegalMonitorStateException,
InterruptedException { . . . }
public final void wait(long millis)
throws IllegalMonitorStateException,
InterruptedException { . . . }
public final void wait(long millis, int nanos) { . . . }
throws IllegalMonitorStateException,
InterruptedException { . . . }
public final void notify() { . . . }
throws IllegalMonitorStateException
public final void notifyAll() { . . . }
throws IllegalMonitorStateException
protected void finalize()
throws Throwable { . . . }
}
The members of Object are as follows:
getClass returns the Class (§20.3) object that represents the class of the object. A Class object exists for each reference type. It can be used, for example, to discover the fully qualified name of a class, its members, its immediate superclass, and any interfaces that it implements. A class method that is declared synchronized (§8.4.3.5) synchronizes on the lock associated with the Class object of the class.
toString returns a String representation of the object.
equals and hashCode are declared for the benefit of hashtables such as java.util.Hashtable (§21.7). The method equals defines a notion of object equality, which is based on value, not reference, comparison.
clone is used to make a duplicate of an object.
wait, notify, and notifyAll are used in concurrent programming using threads, as described in §17.
finalize is run just before an object is destroyed and is described in §12.6.