Object类的所有方法

1.构造方法

public Object(){
        
    }

2、所有方法
(1)clone()

    protected native Object clone() throws CloneNotSupportedException;

创建并返回此对象的副本。
(2)equals(Object obj)

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

指示一些其他对象是否等于此。
(3)finalize()

    protected void finalize() throws Throwable { }

当垃圾收集确定不再有对该对象的引用时,垃圾收集器在对象上调用该对象。
(4)getClass()

    public final native Class<?> getClass();

返回此 Object的运行时类。
(5)hashCode()

    public native int hashCode();

返回对象的哈希码值。
(6)notify()

    public final native void notify();

唤醒正在等待对象监视器的单个线程。
(7)notifyAll()

    public final native void notifyAll();

唤醒正在等待对象监视器的所有线程。
(8)toString()

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

返回对象的字符串表示形式。
(9)wait()

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

导致当前线程等待,直到另一个线程调用该对象的 notify()方法或 notifyAll()方法。
(10)wait(long timeout)

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

导致当前线程等待,直到另一个线程调用 notify()方法或该对象的 notifyAll()方法,或者指定的时间已过。
(11)wait(long timeout, int nanos)

    public final void wait(long timeout, int nanos) throws InterruptedException {
        if (timeout < 0) {
            throw new IllegalArgumentException("timeout value is negative");
        }

        if (nanos < 0 || nanos > 999999) {
            throw new IllegalArgumentException(
                                "nanosecond timeout value out of range");
        }

        if (nanos > 0) {
            timeout++;
        }

        wait(timeout);
    }

导致当前线程等待,直到另一个线程调用该对象的 notify()方法或 notifyAll()方法,或者某些其他线程中断当前线程,或一定量的实时时间。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值