public interface Queue<E> extends Collection<E>
void addLast(E e); // 将元素插入此列表的结尾
E removeFirst(); // 移除并返回列表的第一个元素
boolean isEmpty(); // 判断队列是否为空
package coreJavaOne;
import java.util.LinkedList;
import java.util.NoSuchElementException;
public class SimulateQueue {
private LinkedList<Integer> queue = new LinkedList<Integer>();
public boolean isEmpty() {
return this.queue.isEmpty();
}
public void enQueue(int data) {
this.queue.addLast(data);
}
public int deQueue() throws NoSuchElementException {
return this.queue.removeFirst();
}
public static void main(String[] args) {
SimulateQueue q = new SimulateQueue();
q.enQueue(1);
q.enQueue(2);
q.enQueue(3);
while (! q.isEmpty()) {
int data = q.deQueue();
System.out.println(data);
}
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有