如果我想更改一些数据,但保留一些原始名称,当我按 Enter 时如何跳到下一个用户输入?
for (int i = 0; i < myVector.size(); i++)
{
System.out.println("Press Enter to skip to next input");
System.out.print("Enter Name: ");
//If user presses Enter/newline, go to the next part where it asks for Name2
Name = keyboard.nextLine();
System.out.println("You've entered: " + Name);
myVector.elementAt(i).setName(Name);
System.out.println("Press Enter to skip to next input");
System.out.print("Enter Name2: ");
Name2 = keyboard.nextLine();
System.out.println("You've entered: " + Name2);
myVector.elementAt(i).setName(Name2);
//...etc
}