我正在处理Scanner
语句,该语句接受dateAdmission
的输入,当我在NetBeans中运行时,其中一个输入需要额外的空白输入。当要求用户输入"输入录取日期"时,额外输入发生在变量case "patient":
{
System.out.println("Enter name: ");
String name = in.nextLine();
System.out.println("Enter Address: ");
String address = in.nextLine();
System.out.println("Enter date of birth: ");
String dob = in.nextLine();
System.out.println("Enter MCP number: ");
int mcp = in.nextInt();
in.nextLine();
System.out.println("Enter date of admission: ");
String dateAdmission = in.nextLine();
System.out.println();
String hospital = in.nextLine();
System.out.println("Enter name of doctor: ");
String doctor = in.nextLine();
System.out.println("Enter room number: ");
int roomNum = in.nextInt();
a[i] = new Patient(name, address, dob, mcp, dateAdmission, hospital, doctor, roomNum);
break;
}
。
{{1}}
答案 0 :(得分:2)
您可能忘记提供System.out.println("Enter hospital");
String hospital = in.nextLine();
发生了什么事情,它什么都没有打印,并为医院提供了额外的投入?