object类中的所有方法
时间: 2024-01-24 16:18:46 浏览: 37
Object类是Java中所有类的根类,它包含了一些常用的方法,如下所示:
1. public final Class<?> getClass():返回此 Object 的运行时类。
2. public int hashCode():返回对象的哈希码值。
3. public boolean equals(Object obj):判断对象是否相等。
4. protected Object clone() throws CloneNotSupportedException:创建并返回此对象的副本。
5. public String toString():返回对象的字符串表示形式。
6. public final void notify():唤醒在此对象监视器上等待的单个线程。
7. public final void notifyAll():唤醒在此对象监视器上等待的所有线程。
8. public final void wait(long timeout) throws InterruptedException:在其他线程调用此对象的 notify() 方法或 notifyAll() 方法前,使当前线程等待。
9. public final void wait(long timeout, int nanos) throws InterruptedException:在其他线程调用此对象的 notify() 方法或 notifyAll() 方法,或者超过指定的时间量前,使当前线程等待。
10. public final void wait() throws InterruptedException:在其他线程调用此对象的 notify() 方法或 notifyAll() 方法前,使当前线程等待。
注意:一些方法是final修饰的,因此不能被子类重写。