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的面试题?

posted @ 2019-11-14 21:46  ConstXiong  阅读(420)  评论(0编辑  收藏  举报