Java中何为Object类?

Object类是所有类的父类,所有类在声明的时候默认是对Object类的继承,就像linux系统的根目录“/”一样,是类的起点。

public class Tree
//这句语句与下面这条语句的功能完全一致
public class Tree extends Object

Object类中提供的方法在所有子类中都可以被调用,它一共提供11种方法:

public final native Class<?> getClass()
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
public final void wait(long timeout, int nanos) throws InterruptedException
public final void wait() throws InterruptedException
protected void finalize() throws Throwable { }

猜你喜欢

转载自blog.csdn.net/tiansheshouzuo/article/details/85799164
今日推荐