标签:
堆和栈的区别?
package mianshiti; import java.util.*; public class Stacks { static String[] months={"January","February","March","April","May","June","July","August", "September","October","November","December"}; public static void main(String[] args) { Stack stk=new Stack(); for(int i=0;i<months.length;i++){ stk.push(months[i]+""); } System.out.println("stk="+stk); stk.addElement("The last line");//在末尾添加元素 System.out.println("element 5="+stk.elementAt(5)); System.out.println("popping elements:"); while(!stk.empty()) System.out.println(stk.pop()); } }
标签:
原文地址:http://www.cnblogs.com/GumpYan/p/5746643.html