Unlike the C + + language, the Java language is a single-rooted inheritance structure language, meaning that all classes in Java have a common ancestor. This ancestor is the object class. Structure of the object class
The object class has 12 member methods, which can be divided into the following categories according to usage
1, constructor
The 2,hashcode and Equale functions are used to determine if the object is the same
3,wait (), wait (long), wait (Long,int), notify (), Notifyall ()
4,tostring () and GetClass,
5,clone ()
6,finalize () is used in the garbage collection function to describe the purpose of the Clone () clone () function to save a currently existing object. Hashcode () and Equale ()
Equale () is used to confirm that two objects are the same.
Hashcode () is used to get the hash value of the object, the function of this value is to retrieve, the specific function can refer to here
Objects with the same hash value do not necessarily equale ()
Equale () Two objects that return true must be the same.
ToString () and GetClass () ToString () return a string object that identifies itself
GetClass () Returns a class object that, if printed, finds that the result is the following format class Package.name.xxx 1 because a class object is returned, followed by the class method. Whose constructor is used, then the GetClass return is the type.
GetClass () is often used for the Java Reflection Mechanism wait (), wait (long), wait (Long,int), notify (), Notifyall ()
These functions embody the multithreading mechanism of Java
Required to be used in a synchronize statement when used
Wait () is used to get the current thread out of operation and the current thread enters the wait sequence
Notify () A thread that randomly notifies a lock holding an object to get operation permissions
Notifyall () The thread that is used to notify all the locks that hold the object gets operation permissions
Wait (long) and wait (Long,int) are used to set the time interval at which locks are currently released when the next lock is acquired
Finalize () This function will be used for garbage collection, the anonymous object will be called before the collection, specific examples
---------------------
Two ceremonies
Source: CSDN
Original: 53468038?utm_source=copy
Copyright NOTICE: This article is for bloggers original article, reprint please attach blog link!
What are the methods in OBJCT?