Java string comparison purposes - the difference between == and the equals method

Java string comparison purposes - the difference between == and the equals method

I used to think these two seem very different in java, the fact that I made a big mistake! ! !

This is both a great difference.

If both are constants, and so equal == method is no different.
However, if a string is a variable, another string is constant, so if you want to compare the contents of two strings are equal, it is best to use the equals method. equals method is to compare the contents of a string of equality safest way.

So much for it being. The core idea is just above the. If you want to see an example, then it is a look below this blog.
https://www.cnblogs.com/dongguol/p/5845076.html

Guess you like

Origin blog.csdn.net/ChenglinBen/article/details/91460213