samedi 29 août 2015

Java Scanner If Statement [duplicate]

This question already has an answer here:

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