1. 程式人生 > >Java中何為Object類?

Java中何為Object類?

Object類是所有類的父類,所有類在宣告的時候預設是對Object類的繼承,就像linux系統的根目錄“/”一樣,是類的起點。

public class Tree
//這句語句與下面這條語句的功能完全一致
public class Tree extends Object

Object類中提供的方法在所有子類中都可以被呼叫,它一共提供11種方法:

public final native Class<?> getClass()
public native int hashCode()
public boolean equals(Object obj)
protected native Object clone() throws CloneNotSupportedException
public String toString()
public final native void notify()
public final native void notifyAll()
public final native void wait(long timeout) throws InterruptedException
public final void wait(long timeout, int nanos) throws InterruptedException
public final void wait() throws InterruptedException
protected void finalize() throws Throwable { }