import java.util.*; public class Main { public static void main(String[] args) { Guest guest1 = new Guest("小明", false); Guest guest2 = new Guest("小军", false); Guest vipGuest = new Guest("小红", true); Deque<Guest> deque = new ArrayDeque<>(); deque.add(guest1); deque.add(guest2); // VIP客人优先处理,所以从队列头部插入 deque.addFirst(vipGuest); // 打印当前队列状态,VIP客人应在最前面 System.out.println(deque); } } class Guest{ String name; Boolean vip; @Override public String toString() { return name + (vip ? "" : ""); // 在toString方法中加入VIP标识 } public Guest(String name, Boolean vip) { this.name = name; this.vip = vip; } }