Preface
Unlike the C + + language, the Java language is a single root inheritance structure language, which means that all classes in Java have a common ancestor. This ancestor is the object class. structure of the object class
As the figure shows, the object class has 12 member methods, which can be divided into the following types by use
1, constructors
The 2,hashcode and Equale functions are used to determine whether objects are the same,
3,wait (), wait (long), wait (Long,int), notify (), Notifyall ()
4,tostring () and GetClass,
5,clone ()
6,finalize () is used to describe the clone () in the garbage collection function
The purpose of the Clone () function is to save a currently existing object. hashcode () and Equale ( ) Equale () are used to confirm that two objects are the same. Hashcode () is used to get the hash value of the object, the value of which is retrieved, the effect of which can refer to the same object where the hash value is not necessarily Equale () Equale () returns true two objects must be the same. toString () and GetClass ()
ToString () Returns a String object that identifies itself
GetClass () Returns a class object that, if printed, will find the result to be the following format
Because the return is a class object, the following can be followed by the class method. Whose constructor is used, then the type of GetClass is returned.
GetClass () is often used for Java reflection mechanisms Wait (), wait (long), wait (Long,int), notify (), Notifyall () These functions embody the Java multithreading mechanism The use of Wait () in the Synchronize statement is required when used to let the current thread lose the Operation permission, and the current thread enters the waiting sequence notify () the thread that is used to randomly notify a lock holding the object to obtain the Operation permission Notifyall () The thread that notifies all the locks holding the object gets the action permission wait (long) and long,int to set the next time to acquire the lock the interval of the current release of the Lock Finalize ()
This function is used for garbage collection, which is called before the collection of anonymous objects, as shown in the figure