It's true that
String methods which returns a String (like substring, toUppercase, trim, ...) returns a new String object, and that in most case, the returned String is not equals (regarding == operator) to the String from which the method is called.
The exception is when the method's result is the same litteral than the String reference, the result is the String itself.
So s.substring(0) == s is always true id s is not null.
When you look at Javadoc for the trim() method, it is sayed : "Returns:
A copy of this string with leading and trailing white space removed, or this string if it has no leading or trailing white space.".
But this thing is not specified for some methods.