请帮助,代码有什么问题?我在下面显示此输出。
输入玩家人数:3
输入播放器名称:输入播放器名称:C
输入播放器名称:A
WaitingQueue:[,C,A]
已从WaitingQueue中删除:新的WaitingQueue:[C,A]
从WaitingQueue中删除:C |新的WaitingQueue:[A]
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
Queue<String> waitingQueue = new LinkedList<>();
int num;
System.out.print("Enter number of player: ");
num = s.nextInt();
do
{
System.out.print("Enter player name: ");
String name = s.nextLine();
waitingQueue.add(name);
num--;
}while(num > 0);
System.out.println("WaitingQueue : " + waitingQueue);
String name = waitingQueue.remove();
System.out.println("Removed from WaitingQueue : " + name + " | New WaitingQueue : " + waitingQueue);
name = waitingQueue.poll();
System.out.println("Removed from WaitingQueue : " + name + " | New WaitingQueue : " + waitingQueue);
}
}