首页 > 编程语言 > 详细

Java-Stack

时间:2015-05-17 23:30:30      阅读:200      评论:0      收藏:0      [点我收藏+]

 

 

package 集合类.list类;  
  
import java.util.Date;  
import java.util.Stack;  
  
/** 
 * stack类继承与vector类 
 * @author jjj 
 * 
 */  
public class Stack类 {  
      public static void main(String[] args) {  
  
          Stack s = new Stack();  
  
          s.push("hello");  
  
          s.push(new Date());  
  
          s.push(400);  // 自动封装 , 等价于 s.push(new Integer(400));  
  
          s.push(3.14);  
  
          System.out.println(" 弹栈前 :size=" + s.size());  
  
          System.out.println(s.pop());  
  
          System.out.println(" 弹栈后 :size=" + s.size());  
  
          System.out.println(s.peek());  
  
          System.out.println("peek 操作后 :size=" + s.size());  
  
          while(!s.isEmpty())  
  
                 System.out.println(s.pop());  
  
   }  
}  

 

Java-Stack

原文:http://www.cnblogs.com/hwaggLee/p/4510628.html

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