Java Class - Object

Object 类是 Java 所有类的父类, 所有类默认都是继承这个类,不需要显示的指定 extends.

该类包含以下方法:

  1. public final native Class<?> getClass()

  2. public final native void notify()

  3. public final native void notifyAll()

  4. public final void wait() throws InterruptedException

  5. public final native void wait(long timeout) throws InterruptedException

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

  7. public native int hashCode()

  8. public boolean equals(Object obj)

  9. protected native Object clone() throws CloneNotSupportedException

  10. protected void finalize() throws Throwable

 其中有些方法被声明为final, 也就是说不能被覆写。 在实际的编程中,我们可能会根据需要覆写其他的方法,比如 hashcode 和equal 等方法。

1) getClass

 -获取运行时对象的Class实例

2)  wait

3) notify

4) equal

5) hashCode

6) clone

7) fanalize

猜你喜欢

转载自www.cnblogs.com/mature-mike/p/9499627.html