I'm writing a program to test my knowledge of certain Japanese letters. Basically I want the program to output a random letter such as あ
and then I type my answer a
into the scanner, and if my answer is correct, it will output "Correct" and otherwise "Wrong".
I'm honestly not sure what I'm doing wrong in my program. It all seems logical to me yet my console keeps outputting "Wrong" when my answers are clearly correct:
public class Gojuon {
public static void main(String[] args) {
List<String> list = new ArrayList<String>();
list.add("あ");
list.add("い");
list.add("う");
list.add("え");
list.add("お");
for(int i = 0; i < 3; i++) {
String gojuonLetter = list.get(new Random().nextInt(list.size()));
System.out.println(gojuonLetter);
Scanner scanner = new Scanner(System.in);
System.out.println("Type Romaji:");
String answer = scanner.nextLine();
if(gojuonLetter == "あ" && answer == "a") {
System.out.println("Correct");
} else if(gojuonLetter == "い" && answer == "i") {
System.out.println("Correct");
} else if(gojuonLetter == "う" && answer == "u") {
System.out.println("Correct");
} else if(gojuonLetter == "え" && answer == "e") {
System.out.println("Correct");
} else if(gojuonLetter == "お" && answer == "o") {
System.out.println("Correct");
} else {
System.out.println("Wrong");
}
}
}
}