System.out.println("-----------------------------------------------------------");
System.out.println("Please select a task");
System.out.println("1: List employees with details");
System.out.println("2: List of clients in state");
System.out.println("3: List portfolio of client");
System.out.println("4: Release an employee");
System.out.println("5 Display stocks available for purchase/selling");
System.out.println("6: Display client details");
System.out.println("7: Buy Stock for client ");
System.out.println("0: Exit program");
System.out.println("-----------------------------------------------------------" + "\n" + "\n");
System.out.print("Input:");
Scanner scan = new Scanner(System.in);
input = scan.nextInt();
if (input == 1)
{
System.out.println("length of array list: " + employeeList.size());
int index = 0;
while (index < employeeList.size())
{
System.out.println(employeeList.get(index));
index++;
}
}
else if (input == 2)
{
String state_choice;
System.out.println("Please enter the abbrivation for the state:");
state_choice = scan.nextLine();
这是我具有[否则,如果(输入== 2)当我尝试运行它不会让我输入的问题我目前的代码的一部分并且实际上忽略它。我认为它是因为前一篇文章中的“\ n”。有没有一种方法可以删除该“\ n”或额外的字符,而不需要在我的输入之前放置另一个scan.nextLine()?没有真正看到任何java文档..字符串用java nextLine()空字符
是啊,我的错,我只是固定它,谢谢反正:) –