Object

Object类是java最大的超类,也是最底层的类。

  进入Object类中,其中有很多native修饰的方法:

 1     private static native void registerNatives();
 2     static {
 3         registerNatives();
 4     }
 5     public final native Class<?> getClass();
 6     public native int hashCode();
 7     protected native Object clone() throws CloneNotSupportedException;
 8     public final native void notify();
 9     public final native void notifyAll();
10     public final native void wait(long timeout) throws InterruptedException;

  这些方法都是java自身不能实现的,相当于是一个对别的语言的接口(例如:C,C++)。想要深究,首先要清楚JNI的原理和关键字native的作用。

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

  equals方法是用来比较两个对象的引用是否相同,如果两个对象具有相同的引用

 

  

 

posted on 2015-04-23 20:55  00醉酒00  阅读(124)  评论(0)    收藏  举报

导航