Possible Duplicate:
How do I compare strings in Java?
import java.util.Scanner;
public class stringComparer {
public static void main(String[] args) {
Scanner scan = new Scanner (System.in);
System.out.println ("Enter 1 word here - ");
String word1 = scan.next();
System.out.println ("Enter another word here - ");
String word2 = scan.next();
if (word1 == word2) {
System.out.println("They are the same");
}
}
}
I had it working about 10 minutes ago, changed something and it now it doesn't display "They are the same" for some reason? Its really simple yet I can't see where I've gone wrong.
Thanks!