# 每個 class 的父類別:java.lang.Object ###### tags: `java` `object` `inherit` `clone` `equals` `finalize` `getClass` `hashCode` `toString` The methods inherited from ```Object``` that are discussed in this section are: * ```protected Object clone() throws CloneNotSupportedException``` Creates and returns a copy of this object. * ```public boolean equals(Object obj)``` Indicates whether some other object is "equal to" this one. * ```protected void finalize() throws Throwable``` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object * ```public final Class getClass()``` Returns the runtime class of an object. * ```public int hashCode()``` Returns a hash code value for the object. * ```public String toString()``` Returns a string representation of the object. The ```notify```, ```notifyAll```, and ```wait``` methods of ```Object``` all play a part in synchronizing the activities of independently running threads in a program, which is discussed in a later lesson and won't be covered here. There are five of these methods: * ```public final void notify()``` * ```public final void notifyAll()``` * ```public final void wait()``` * ```public final void wait(long timeout)``` * ```public final void wait(long timeout, int nanos)``` > Note: There are some subtle aspects to a number of these methods, especially the clone method. ## ```clone()``` ## ```equals()``` ## ```finalize()``` ## ```getClass()``` ## ```hashCode()``` [Baeldung](https://www.baeldung.com/java-hashcode) ## ```toString()``` ## 參考資料 * [Java Tutorials](https://docs.oracle.com/javase/tutorial/java/IandI/objectclass.html)