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'? –