java.util
接口 Queue<E>
- 类型参数:
-
E
- collection 中所保存元素的类型。
- 所有超级接口:
- Collection<E>, Iterable<E>
- 所有已知子接口:
-
BlockingDeque<E>,
BlockingQueue<E>,
Deque<E>
- 所有已知实现类:
-
AbstractQueue, ArrayBlockingQueue,
ArrayDeque,
ConcurrentLinkedQueue,
DelayQueue, LinkedBlockingDeque,
LinkedBlockingQueue,
LinkedList,
PriorityBlockingQueue,
PriorityQueue, SynchronousQueue
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack; public class Main {
public static int[][] mp = new int[55][55];
public static char[] st = new char[1005];
public static char[] end = new char[1005]; public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
// 涉及到大量字符串拼接时不要用String, 而用StringBuilder
StringBuilder st = new StringBuilder();
// st.append(cin.next()); // System.out.println(st); // java中的栈
Stack<Integer> sta = new Stack<Integer>();
// java中的队列:queue接口有很多实现类,建议查询jdk文档
Queue<Integer> que = new ArrayDeque<>(); que.add(1);
que.add(2);
que.add(9);
que.add(2); System.out.println(que.toString()); System.out.println(que.peek());
System.out.println(que.toString());
System.out.println(que.poll());
System.out.println(que.toString()); }
} /*
abcd
dddd
3
a b
b c
c d
*/