hi i want to use JOption and Scanner for if and else, that if the word is correct than do the if statement , and ether do the else statement, but the problem is it always do the else statement. but it dose work if i put the word directly.
public static void main(String[] args) {
String name = JOptionPane.showInputDialog(null, "test");
if (name == "apple") {
System.out.println("Correct");
} else {
System.out.println("Uncorrect");
}
}
Aucun commentaire:
Enregistrer un commentaire