+ 1
[ANSWERED]String concatenation
String a = "a", b ="b", c="ab"; I know from testing that a+b!=c Any brief answers why it is so?
1 Réponse
+ 5
In java String is an object type.
!= and == it's a reference comparison.
Different references reference different objects with the same content.
To compare content use method
(object1).equals(object2)
String is immutable object.
When you concatenate strings a new string object is built.