As Anand said, always use String.equals for comparing String contents.
The == operator (for non-primitives) returns true if both expressions point to he same object. Since
Java pools Strings, the two expressions in your first example both point to the same object.
So the == symbol worked as expected but probably not for the reasons that you thought.
In your second example, you compared the contstant "String" with the result of the trim() method which returns a new instance of String. So.. even though the contents of the two strings match the two expressions did not return references to the same String object.
Try the same experiment using the .equals operator instead of the == operator.
[ January 26, 2008: Message edited by: Ben Souther ]