The object class and The Equals () method

Source: Internet
Author: User

1 = = for the base data type, the values on both sides determine whether they are equal, and return true even if the data types are different on either end. Reference data types, comparing addresses that reference variable types are equal

2 equals () is a comparison of reference-type variables for equality and also for comparing address values

3 ctrl+shift+t View Source code

 PackageLianxi2; Public classTestequals { Public Static voidMain (String []args) {Department D1=NewDepartment (); Department D2=NewDepartment (); System.out.println (D1==D2); System.out.println (D1.equals (D2)); //the Equals method of objectString S1=NewString ("TT"); String S2=NewString ("TT"); System.out.println (S1==S2);  System.out.println (s1.equals (S2)); //The string class overrides the Equals method    }}

The object class and The Equals () method

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.