4 years ago (2016-03-18)  Technology |   First to comment  14 
post score 0 times, average 0.0

For some basic data types, int, long, bool, and char!, "==" means that the value is equal, there is no equal method. The equal method is the method inside the object object. In Java, String is not a basic data type, but a class, they are all inherited from the object class, and the difference between Integer and int is Integer is a class! In the object class, the equal method is equivalent to "==", and "==" does not mean that the values ​​are equal, but the address of the comparison object is equal!Both Integer and String are rewritten (yes!Is to rewrite, overload is to write multiple functions with the same name but different parameters; rewrite is a re-definition of the parent class, reflecting the polymorphism), the equal method after the String, Integer rewrite, is a comparative value Instead of the address.

 

This article has been printed on copyright and is protected by copyright laws. It must not be reproduced without permission.If you need to reprint, please contact the author or visit the copyright to obtain the authorization. If you feel that this article is useful to you, you can click the "Sponsoring Author" below to call the author!

Reprinted Note Source: Baiyuan's Blog>>https://wangbaiyuan.cn/en/language-java-1-difference-between-equal-2.html

Post comment

Style

No Comment

登录

Forget password?

您也可以使用第三方帐号快捷登录

切换登录

注册

TW