Question: Determine if a string s is an empty string ""
Error method: s!= "" or s== ""
S!= "" or return True if string s is an empty string
The difference between = = and equals
Conclusion: Strings are object types and cannot be used to determine equality
Equals () compares the contents of the object (which distinguishes the case of letters), but is not equal if you compare two objects with "= =", compared to the memory addresses of two objects. Even though their contents are equal, the memory addresses of different objects are not the same.
The string is first an object.
As an example:
String STR0 = "abc";
String str1 = new String ("abc");
When executing string STR0 = "abc", the JVM creates three char-type values ' A ', ' B ' and ' C ' in the stack, and then creates a string object in the heap whose value is the array {' A ', ' B ', which consists of the three char-type values created in the stack just now , ' C '}, the value "ABC" of the newly created string object is added to the string pool. If we proceed to string Str1=new string ("abc"), the code, since "ABC" has been created and saved in the string pool, will only create a new string object in the heap, but its value is the "ABC" in the string pool to share the previous line of code execution;
Java string comparison