Two important methods about the object class and why overriding equals must rewrite Hashcode ()

Source: Internet
Author: User

ToString ()----------------------The value of the output object after the address of the output object is rewritten
object. Equals (object)---------------Compare the memory address overrides of two objects by comparing the properties of two objects (always overriding the Hashcode () method, because instance ab behaves equal by Equals, But they exist in the HashMap hashcode is still not the same)

The other more important methods of the object class are:

GetClass (): Gets the Class object (which emphasizes the code information of the class, the object of the class emphasizes the value of the class Code information) hashcode (): Unique object-sensitive (object address string) clone () Thread: Notify (), Notifyall (), Wait ()

Two important methods about the object class and why overriding equals must rewrite Hashcode ()

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.