我在这里遇到了这个 do-while 循环的问题。第一次运行顺利,但第二次询问国家后,它不会让我输入。有什么帮助吗?
import java.util.*;
public class UseList
{
public static void main(String[] args)
{
Scanner userInput = new Scanner(System.in);
ListInterface<String> list = new ArraySortedList<String>();
String country, flag;
char flagCharred;
do
{
System.out.print("Enter a country you've visited: ");
country = userInput.nextLine();
list.add(country);
System.out.print("\n" +list);
System.out.print("\nAdd another country?: Y/N ");
flag = userInput.next();
flagCharred = flag.charAt(0);
}
while (flagCharred == 'y' || flagCharred == 'Y');
}
}