0
System.out.println("What hero are you playing?");
Scanner console = new Scanner(System.in);
Scanner value = new Scanner(System.in);
String character = console.next();
String[] hero = {"x1", "x2", "x3", "x4"};
if(Arrays.asList(hero).contains(character)) {
System.out.println("hero selected: "+ character);
}
else {
System.out.println("hero not found");
}
我希望它運行,直到一個正確的英雄名字被髮。如果輸入了錯誤的名字,它應該再次提出要求。循環直到正確的輸入