When to use the difference between equals and ==

As far as I understand, byte, short, char, int, long, float, double, boolean and other types of data need to be directly compared with ==.

If it is a string, generally use equals to compare, because if the attribute in the object is a string, then == is wrong, because it will compare the memory address.

 

Published 7 original articles · won 5 · visited 4120

Guess you like

Origin blog.csdn.net/blue_heart_/article/details/87877152