You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The String class is final and String objects are immutable.
🔴 String Equality
In order to see if two strings are equal in content, you must use .equals() rather than == which checks for reference equality.
E.g.
Strings1 = "bunny";
Strings2 = "bunny";
Strings3 = newString("bunny");
s1 == s2; // true as string pool can reuse references1 == s3; // false - using constructor creates new String in pools2 == s3; //false - same as above
🔴 String Concatenation
String concatenation is achieved using + operator. The result creates a brand new String with the two strings concatenated.