Queue and stack

来源:互联网 发布:显卡软件超频 编辑:程序博客网 时间:2024/05/16 10:45
@Test
    public void testChar(){
        Queue<String> queue= new LinkedList<String>();
        queue.offer("a");
        queue.offer("b");
        queue.offer("c");
        queue.offer("d");
        queue.offer("e");
        System.out.println("队列中的元素是:"+queue);
        queue.poll();
        System.out.println("队列中的元素是:"+queue);
        String peek = queue.peek();
        System.out.println(peek);
        System.out.println("队列中的元素是:"+queue);
        
        Stack<String> stack=new Stack<String>();
        stack.push("11");
        stack.push("12");
        stack.push("13");
        stack.push("14");
        stack.push("15");
        System.out.println("栈中的元素是:"+stack);
        System.out.println(stack.peek());
        stack.pop();
        System.out.println("pop后栈中的元素是:"+stack);
        
    }
   
0 0