Common Object class Methods

public final native Class <?> getClass () // native method for returning the current runtime object Class object, use the
keyword final modification, it does not allow subclasses override.
public native int hashCode () // native method for Returns the hash code is mainly used in the hash table, such as in the JDK
HashMap。
public boolean equals (Object obj) // for comparing two objects of the memory address are equal, String class the method is rewrite user
Comparing string values ​​are equal.
protected native Object clone () throws CloneNotSupportedException // naitive method for creating and returns
A copy of the current object. In general, for any object x, the expression x.clone ()! = X is true, x.clone (). GetClass ()
== x.getClass () is true. Object itself does not implement the Cloneable interface, it does not override the clone method call and then will occur
CloneNotSupportedException exception.
public String toString () // returns the name @ instance of the class hexadecimal string hash code. Object recommended all subclasses override this party
law.
public final native void notify () // native method, and can not be overridden. Wake up a thread waiting on this object's monitor (monitor
Is equivalent to the concept is the lock). If there are multiple threads waiting for a wake up only arbitrary.
public final native void notifyAll () // native method, and can not be overridden. Like notify, the only difference is wake up
All threads waiting on this object's monitor, rather than a thread.
public final native void wait (long timeout) throws InterruptedException // native method, and can not be
Rewriting. Suspended execution threads. Note: sleep method does not release the lock, and wait method releases the lock. timeout is the wait time.
public final void wait (long timeout, int nanos) throws InterruptedException // more nanos parameters,
This parameter represents the extra time (in nanoseconds, the range 0-999999). So timeout also need to add nanos milliseconds.
public final void wait () throws InterruptedException // 2 Ge wait before with the same method, but this method has been waiting for
To be no concept of timeout
protected void finalize () throws Throwable {} // instance is recovered when the garbage collector is triggered operation

Guess you like

Origin www.cnblogs.com/xiaolan-/p/12324438.html