In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly talks about "what's the difference between Java (=) and equals". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "what's the difference between Java (=) and equals?"
The data types in java can be divided into two categories:
1. Basic data type, also known as primitive data type byte,short,char,int,long,float,double,boolean
The comparison between them, using a double equal sign (=), compares their values.
two。 Compound data type (class)
When they compare with (= =), they compare their storage address in memory, so unless it is the same new object, their comparison result is true, otherwise the comparison result is false. All the classes in JAVA inherit from the base class Object. An equals method is defined in the base class in Object. The initial behavior of this method is to compare the memory address of the object, but this method is overwritten in some class libraries, such as String,Integer,Date. Equals has its own implementation in these classes, rather than comparing the address of the class stored in heap memory.
For equals comparison between composite data types, without overriding the equals method, the comparison between them is based on the address value of their location in memory, because the equals method of Object is also compared with a double equal sign (= =), so the result of the comparison is the same as that of the double equal sign (= =).
At this point, I believe you have a deeper understanding of "what is the difference between Java (=) and equals". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.