java.lang.Object的常用方法?


  • public final native Class<?> getClass(); 獲取類結構信息
  • public native int hashCode() 獲取哈希碼
  • public boolean equals(Object) 默認比較對象的地址值是否相等,子類可以重寫比較規則
  • protected native Object clone() throws CloneNotSupportedException 用於對象克隆
  • public String toString() 把對象轉變成字符串
  • public final native void notify() 多線程中喚醒功能
  • public final native void notifyAll() 多線程中喚醒所有等待線程的功能
  • public final void wait() throws InterruptedException 讓持有對象鎖的線程進入等待
  • public final native void wait(long timeout) throws InterruptedException 讓持有對象鎖的線程進入等待,設置超時毫秒數時間
  • public final void wait(long timeout, int nanos) throws InterruptedException 讓持有對象鎖的線程進入等待,設置超時納秒數時間
  • protected void finalize() throws Throwable 垃圾回收前執行的方法

 

 

  

來一道刷了進BAT的面試題?


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM