when you use == with a primitive -int,double , char ... you are checking that the values are identical . but if you use == with an object , you are checking that the 2 objects are stored at the same address. in other words the references pointing to the same object..
Method equals() is different.
it's the same as ==,if it isn't overriden by the object class.
many classes override the method equals().In this case this mehtod will check that content of the object is the same or not,not address.
If this String object represents an empty character sequence, or the first and last characters of character sequence represented by this String object both have codes greater than '\u0020' (the space character), then a reference to this String object is returned.
喝喝
TIJ :
You can see that every String method carefully returns a new String object when it’s necessary to change the contents. Also notice that if the contents don’t need changing the method will just return a reference to the original String. This saves storage and overhead.