Don't use == to compare Strings. Use the String.equals method. Search the forum for the reasons why. It's been explained many times.
Actually having just re-read your post, you may have been wondering why x==y returned true while z==y returned false. If that's the case you need to search the forum (or read the Java language Specification) for an explanation of the string pool. [ August 14, 2008: Message edited by: Joanne Neal ]
In 'String x = "Java";', '"Java"' is a compile time constant, thus the String pool gets into action, resulting in x and y atually refering to the same object, not only to Strings that are equal. Therefore, x == y is true.
In 'String z = new String("Java");' in contrast, a new String object is created, which is not the same as the one referenced by x and y. Consequently, x == z is false.