Scanner one = new Scanner(System.in);
System.out.print("Enter Name: ");
name = one.nextLine();
System.out.print("Enter Date of Birth: ");
dateofbirth = one.nextLine();
System.out.print("Enter Address: ");
address = one.nextLine();
System.out.print("Enter Gender: ");
gender = //not sure what to do now
您好我一直試圖算出這個自己,但我不能完全從尋找其他的例子得到它,大多數要麼只接受某些字符或A-Z + AZ如何讓掃描儀循環讀取所需的字符串?
我想使程序只接受男性或女性的輸入而忽略案件,如果輸入錯誤重複「輸入性別:」直到輸入正確的值。
我不覺得'''java.util.Scanner''',對於解析互動(人)輸入有用。我使用''''''java.io.BufferedReader.readLine()''''''while'''''''''''''''' –
如何找不到用於解析輸入的'java.util.Scanner'? –