Parsing the Java-object class

Source: Internet
Author: User

The object class is the parent class of all classes, and the array is also a subclass of the object class

Objects of any class can call methods in the object class, including array objects

Object () when the parameter is of type object, any type of argument can be passed into the execution

Object[] When a parameter is an array type, only the array object can be passed into the execution

Ii. common methods of object class

ToString Method: You can convert any object to a string return

Equals method: Used to compare the virtual addresses of two references, returns True if and only if two references are physically the same object, or returns flase

Hashcode method: Gets the hash code value of the object, which is 16 binary

The Equals method relates to the Hashcode method: If two objects return true using Equals, their hashcode values must be the same

If the equals of two objects returns false, their hashcode values are not necessarily different

overriding equals, which often requires overwriting hashcode, can be generated automatically using eclipse, guaranteeing that equals returns True, Hashcode is the same; equals returns false, Hashcode different

There are practical applications in the Set collection section

Parsing the Java-object class

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.