Method of Object class

Source: Internet
Author: User
Tags garbage collection
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.