请指正有不足的地方 import java.util.*; import java.io.*; class stack1 { public static void main(String args[]) { operate he=new operate(); int k;int y=1; DataInputStream ha1=new DataInputStream(System.in); while(y!=0) {try {he.menu(); k=Integer.parseInt(ha1.readLine()); switch(k) {case 1 :{he.enter();break;} case 2 : {he.remove();break;} case 3 : {he.display();break;} case 4 : {he.clear();break;} case 5 : {y--;break;} default :break; } } catch (Exception e) {System.out.println("---input error,please input
right order");} } } } class operate { ArrayList al=new ArrayList(); void menu() {System.out.println("-----menu of the program"); System.out.println("1).enter the value in the
stack"); System.out.println("2).remove the last value from
the stack"); System.out.println("3).display the value"); System.out.println("4).clear all the value"); System.out.println("5).exit"); System.out.print("I choose:"); } void enter() {int y=1,k; DataInputStream ha2=new DataInputStream(System.in); while(y!=0) { try { System.out.print("enter you number :"); int i; i=Integer.parseInt(ha2.readLine()); al.add(new Integer(i)); y--; System.out.println("--type 1 to enter more"); k=Integer.parseInt(ha2.readLine()); if(k==1) y++; } catch (Exception e) {} } } void remove() { int i,y=1,k; i=al.size(); if(i!=0) { DataInputStream ha3=new DataInputStream(System.in); while(y!=0) {try {al.remove(i-1); i=i-1; System.out.println("--type 1 to remove more"); k=Integer.parseInt(ha3.readLine()); if(k==1) y++; } catch (Exception e) {} } } else System.out.println("--null"); } void display() { int i; i=al.size(); if(i!=0) System.out.println(al); else System.out.println("--null"); } void clear() { al.clear();} }