package java.lang;
public class Object {
private static native void registerNatives(); //调用非java代码写的方法
static {
registerNatives();
}
public final native Class<?> getClass(); //调用非java代码写的方法
public native int hashCode(); //调用非java代码写的方法
public boolean equals(Object obj) {
return (this == obj); //这个就是我们熟悉的比较两个对象是否相等的方法。一般都会被子类重写
}
protected native Object clone() throws CloneNotSupportedException; //调用非java代码写的方法
public String toString() {
return getClass().getName() + "@" + Integer.toHexString(hashCode()); //这个就是toString方法。
}
public final native void notify(); //调用非java代码写的方法
public final native void notifyAll(); //调用非java代码写的方法
public final native void wait(long timeout) throws InterruptedException; //调用非java代码写的方法
public final void wait(long timeout, int nanos) throws InterruptedException {
if (timeout < 0) {
throw new IllegalArgumentException("timeout value is negative");
}
if (nanos < 0 || nanos > 999999) {
throw new IllegalArgumentException(
"nanosecond timeout value out of range");
}
if (nanos >= 500000 || (nanos != 0 && timeout == 0)) {
timeout++;
}
wait(timeout);
}
public final void wait() throws InterruptedException {
wait(0);
}
protected void finalize() throws Throwable { }
}
重点看其中方法:
hashCode()
equals()
clone()
toString()
finalize()
还有线程的一些 唤醒 阻塞 方法