Class Object: Selected Methods


 o public Object clone() throws CloneNotSupportedException, OutOfMemoryError
Creates a new object of the same class as this object. References are copied as references and will point to the same object. To prevent this, clone can be overwritten ( implement Clonable interface).
 o public boolean equals(Object other)
Compares two Objects for equality. Should be overwritten if a class uses references (recursive call equals to contained classes).
 o protected void finalize() throws Throwable
Destructor method. Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. Empty, should be overwritten, when needed.
 o public String toString()
Returns a string representation of the object. Often used for debugging. Contains the name and qualifying parameters. (Should be overwritten.)
 o public final Class getClass()
Returns the runtime class of an object. See Class

Java Tutorial - Standard Classes Jens Trapp, 1997