1. 程式人生 > >Java基礎知識總結 (一) Object 常用方法

Java基礎知識總結 (一) Object 常用方法

  1. java.lang Object:是所有繼承類的的根類子類的構造方法預設訪問的是父類的無參構造方法
  2. java.lang Object 類的方法
    public final native Class<?> getClass() //返回此 Object 執行時的類
    public final native Class<?> getClass() //返回此 Object 執行時的類
    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 //使當前物件的執行緒等待 timeout 時長
    public final void wait(long timeout, int nanos) throws InterruptedException //使當前物件的執行緒等待 timeout 時長,或其他執行緒中斷當前執行緒
    public final void wait() throws InterruptedException //使當前物件的執行緒等待
    protected void finalize() throws Throwable {} //垃圾回收處理