object类里面的方法

object类中的方法

1.toString

打印对象的信息,返回对象的字符串表示

public String toString() {
    return getClass().getName() + "@" + Integer.toHexString(hashCode());
}

2.finalize

垃圾回收时调用

protected void finalize() throws Throwable { }

3.equals,比较两个对象的地址值是否相等

public boolean equals(Object obj) {
    return (this == obj);
}

4.clone

返回并创建该对象的一个副本

5.返回该对象的hash码值

public native int hashCode();

6.getClass()

反射,返回该对象运行 时的一个类

下面时多线程相关的几个方法

7.notify唤醒等待的单个线程

ublic final native void notify();

8.notifyAll

唤醒等待的全部线程

public final native void notifyAll();

9.线程等待

public final native void wait(long timeout) throws InterruptedException;

10.纳秒,更加精确的表示

public final void wait(long timeout, int nanos) throws InterruptedException 

11.0s?

public final void wait() throws InterruptedException {
    wait(0);
}

猜你喜欢

转载自blog.csdn.net/qpc672456416/article/details/80726681