import java.util.Scanner;
public class testing {
public static void main(String args[]) {
String answer;
System.out.println("Answer with a yes or no.");
Scanner in = new Scanner(System.in);
answer=in.nextLine();
if (answer=="yes") {
System.out.println("Sounds like fun! Wait for me!"); }
else if (answer=="no") {
System.out.println("Hm..that might be a good choice."); }
else {
System.out.println("Are you speaking alien language?"); }
}
}
Even though I type in "yes" or even "no" in the console, it only comes out as the else: "Are you speaking alien language?"
How do I make "Sounds like fun! Wait for me!" to come out if I type in "yes"?
Aucun commentaire:
Enregistrer un commentaire