Hashcode (); Wait (); notify (); equals (); GetClass (); toString (); clone (); Finalize ();
Here is a brief introduction to several of these functions:
Hashcode ():
* as much as is reasonably practical, the Hashcode method defined byclassreturnfor distinct * objects. (This was typically implemented by converting the internal This implementation * Technique is not required by the * java™ programming language.)
This is part of the explanation in the official Java documentation, simply to return an integer value that is converted through the internal address of the object , which can be internal via getclass (). method to see the specific value of the display is the number of hexadecimal, sometimes this method can be used to determine whether the object reference is equal, when studying Java memory, this may be useful.
Equals ():
All know that comparing strings in Java should be equal to equals (), and = = is the comparison value, that is, the reference; So why is this? I looked at the implementation method of equals today, and found that the comparison of strings is by comparing each character, and if all are equal, returns true; and the source of the object type Equals method is directly used = = to replace , that is, the equivalent of direct comparison reference, which is why we sometimes have to rewrite the Equals method, the following is attached to the JDK string type equals method source code.
Public Booleanequals (Object anobject) {if( This==anobject) { return true; } if(AnObjectinstanceofString) {String anotherstring=(String) AnObject; intn =value.length; if(n = =anotherString.value.length) {CharV1[] =value; CharV2[] =Anotherstring.value; inti = 0; while(n--! = 0) { if(V1[i]! =V2[i])return false; I++; } return true; } } return false; }
GetClass ():
ToString ():
In the following example, J is a simple Java object, followed by the output of the ToString () method and the GetClass () method, followed by the hash code, which is the memory address, and GetClass () returns the runtime class.
There are GetName (), Getsimplename () method, these can be viewed by the method of source code to understand the usage, see the source is really a good way to learn.
System.out.println (j.tostring ()); System.out.println (J.getclass ()); [Email protected] class Com.wust.cvte.j2se
Clone ():
Chinese "clone" meaning, just at the beginning I see the source of the comments, not very understand, and later on the internet to see some blogs, understand the Clone method is actually realized a shallow copy, with a detailed description of this method of the blog, there is a picture of the truth, particularly detailed, http://blog.csdn.net/ zhangjg_blog/article/details/18369201#0-qzone-1-28144-d020d2d2a4e8d1a374a433f596ad1440
Other methods related to thread and memory recycling, GG, etc., to use the time to do record it, if there is not correct, welcome to testify.
Public methods of the object class in Java