The general method *** object

1.equals: an address comparator is implemented to determine whether the two target objects are equal, a rewritable, is very important, is the same in java by comparing two objects equals the (equal).

2. (The only use is to use hashmap, set and other containers to improve efficiency in Comparative) hashCode (), a numerical value of the address generated by an object, not before rewriting can uniquely identify an object, Why should this method the main reason is the use hashmap, to ensure that these two data do not overlap when the container set.

hashmap: Use hashcode () Returns the hash values ​​are mapped to a location in the map by calculating the hash function, if the Location element is called equals () method comparison are the same, different hash conflict is resolved, the same give up.

set: By the same token, set does not allow duplicate elements, use hashcode resolved.

hashcode can be rewritten.

Return true equals object () method, the two objects have the same hashcode (set to be stored as duplicate data).

Not necessarily the same hashcode same object.

3.registerNative () function is to register with the local methods virtual machine, so that when the program calls the native method, jvm can find these methods.

4.getclass () Returns the current class of the class object, for reflecting.

Copy of a copy of the object 5.clone (), is to protect, to the child class overrides a pale copy.

6.tostring () Returns a string that identifies the object form, easy to print, to understand the object information.

7.wait (), wait (long) waitr (long, int) for inter-thread communication, blocking the current thread

8.notify / notifyall wake wait thread.

9.finalize () object calls this method before it is recycled, see if you can back to life.

Guess you like

Origin www.cnblogs.com/gmzqjn/p/11704605.html