我必须在我的代码中使用一个循环,这样当有人输入是时,他们可以根据需要多次重新输入他们的名字,但我不知道该怎么做。任何帮助表示赞赏,这是我的代码:
public static void main(String [] args)
{
// Create a Scanner object to read input.
Scanner keyboard = new Scanner(System.in);
//Get the user's name.
System.out.print("What is your name?");
String name = keyboard.nextLine();
System.out.println("Hello there," + name);
System.out.println("Would you like to enter another name? Please enter Yes Or No.");
String reply = keyboard.nextLine();
if (reply == "yes")
{
}
}
}