首页 > 其他 > 详细

Stack

时间:2018-02-20 23:29:00      阅读:266      评论:0      收藏:0      [点我收藏+]

Stack: LIFO, 

the Stack is a deprecated interface we should use Deque interface. The implementation can use LinkedList or array

push, pop, peek, size(), isEmpty()

public static void main(String[] args){
    Deque<Integer> stack = new LinkedList<>() ;
    stack.push(5);
    stack.push(3);
    System.out.println(stack.size()); //2
    System.out.println(stack.pop()); //3
    System.out.println(stack.peek()); //5
    System.out.println(stack.isEmpty()); //false
    System.out.println(stack.pop()); //5
    System.out.println(stack.isEmpty()); //true
    
}

 

Stack

原文:https://www.cnblogs.com/davidnyc/p/8455975.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!