JAVA SE Learning Summary

Source: Internet
Author: User
1. Equal to the same

If two objects have the same type and the same property value, the two objects are said to be equal (equal), and if the two reference variables point to the same object, the two variables (objects) are called the same (identical). If two objects are the same, two objects are definitely equal, and conversely, if two objects are equal, they are not necessarily the same. When you use the usual equals "=" to determine whether the two objects are "equal," you actually determine whether the two objects are the same.

The function of the Equals () method in the object class: Compares whether the recipient object and the Parameter object are the same object, that is, whether the address of the object is the same. Therefore, the Equals () method in the object class determines whether two objects are the same, rather than judging whether the values of the individual domains of the two objects are equal.

To determine whether the values of the individual domains of the two objects are the same, you cannot use the Equals () method inherited from the object class, but you need to override the Equals () method in the class declaration.
The Equals method is required to compare whether the value of two strings is equal and cannot be used as equals "=". The Equals method has been overridden in the string class to compare the values of two strings for equality.

JAVA SE Learning Summary

Related Article

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.