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 {} //垃圾回收处理

猜你喜欢

转载自blog.csdn.net/weixin_43870026/article/details/85251494