= = and the sentiment of equal application in Java

Source: Internet
Author: User

Today is a long time to see. Know the difference between the equal and = = that are not noticed at ordinary times.

either = = or equal are used to compare the same or not. When the problem is here, what's the difference?

My daily comparison is nothing more than two kinds: 1, the comparison between the basic data types, 2, the comparison between the reference type data.

1. When comparing the basic data types. = = is the same as equal. is a comparison of two values that are the same, and the same as true differs from false.

2. When comparing the reference data types. = = is the same as equal, which is the same as the address in the stack memory, the same as true. The difference is false.

In general, there will always be a very individual thorn head, here is no exception. String. We all know that this is a special reference type, for two string comparisons, whether = = or equal

The comparison between the two comparisons is whether the strings are identical.

Extension: We know that if you create two string objects, the address of the memory is different.

= = and the sentiment of equal application in Java

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.