This question already has an answer here:
- How do I compare strings in Java? 23 answers
I don't know why this isn't working. Thanks very much.
public String name;
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter your name....");
String input = scanner.next();
if (input == "judy") {
System.out.println("Hello judy, its so nice to have you here");
}
When I enter judy, it doesn't print "Hello....". Why?
Aucun commentaire:
Enregistrer un commentaire