- 1 package Test;
- 2 import java.util. * ;
- 3 public class Queue_test {
- 4 5 public static void main(String[] args) {
- 6 // TODO 自动生成的方法存根
- 7 // 输入与字符处理
- 8 Scanner scanner = new Scanner(System. in );
- 9 String string = scanner.nextLine();
- 10 String[] string2 = string.split("");
- 11 12 //创建队列,并且将字符串插入队列里面
- 13 Queue queue = new LinkedList();
- 14
- for (int i = 0; i) {
- 15 queue.add(string2[i]);
- 16
- }
- 17 System.out.println("queue is: " + queue);
- 18 //移除队列元素
- 19 System.out.println("remove: " + queue.remove());
- 20 System.out.println("queue is: " + queue);
- 21
- }
- 22 23
- }
来源: http://www.bubuko.com/infodetail-1869847.html