This question already has an answer here:
- How do I compare strings in Java? 23 answers
I want to be able to make this work but for some reason it isn't initiating.
Scanner userInput = new Scanner(System.in);
System.out.println("Welcome to black jack. Are you ready to play?\nEnter 'Yes' or 'No'.");
System.out.println(""); //line spacing
String confirm = userInput.nextLine();
System.out.println(""); //line spacing
if (confirm == "Yes") {
System.out.println("Testing");
//going to put code to play game in here
} else if (confirm == "No") {
System.out.println("Testing 2");
System.exit(0);
} else {
System.out.println("ERROR");
System.out.println(""); //line spacing
}
Aucun commentaire:
Enregistrer un commentaire