堆栈的基本使用初始化Stack stack=new Stack判断空的stack.empty )是否取堆栈的最高值(不提取堆栈) stack.push 堆栈stack.pop (; 示例: public class te st01 { publicstaticvoidmain (字符串[ ] args ) {堆栈=new堆栈); //1.empty ()堆栈为空的system.out.println (stack.empty ) ); //2.peek (堆栈顶值3 .推送) ) stack.push ) newinteger(1); 斯塔克. push (b ); 系统. out.println (stack.peek ) ); //4.pop ) )堆栈stack.pop ); 系统. out.println (stack.peek ) ); }