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();
Это часть моего текущего кода, у меня возникают проблемы в [else if (input == 2)], когда я пытаюсь его запустить, он не позволяет мне вводить, а просто игнорирует его на самом деле. Я думаю это из-за "\ n" из предыдущей записи. Есть ли способ удалить этот "\ n" или лишний символ, не помещая еще один scan.nextLine () перед моей записью? На самом деле ничего не видел в документах Java ..