1、Object是所有类的父类,默认会继承Object。
2、Object类中常用的方法有:getClass()、hashCode()、equals()、clone()、toString()、finalize(),
除此之外还有registerNatives()、notify()、notifyAll()、wait()。
3、final native 修饰的有:getClass()、notify()、notifyAll()、wait()
native修饰的有:hashCode()
final修饰的有:clone()
4、equals方法源码:
public boolean equals(Object obj){
return this == obj;
}
toString方法源码:
public String toString(){
return getClass().getName() + "@" +Integer.toHexString(hashCode());
}
5、特别的一点:Object存在一个静态块,静态块里面初始化着一个 static native方法:registerNatives()
创建对象时,先调用静态代码块(即registerNatives()方法),。native关键字表示该方法不是由java语言编写,而是通过C/C++来完成的,并被编译成.dll 之后才由Java调用,方法的具体实现是在dll文件中。registerNatives()方法主要作用就是将C/C++中的方法映射到Java中的native方法,实现方法命名的解耦。