InterfaceTest Class
 1 import java.io.*;
 2 public class InterfaceTest 
 3 {
 4     private static BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
 5     public static void main(String[] args)
 6     {
 7         
 8         Stack stack = new Stack();
 9         
10         String s1 = "";
11 
12         while(!s1.equals("exit"))
13         {
14 
15             System.out.println("please input int:");
16             try
17             {
18                 s1 = stdIn.readLine();
19                 if(s1.equals("exit"))
20                     break;
21 
22             }
23             catch(Exception e2)
24             {
25                 System.out.print(e2);
26             }
27             int i1;
28             try
29             {
30                 i1 = Integer.parseInt(s1);
31                 
32             }
33             catch(Exception e3)
34             {
35                 System.out.println(e3);
36                 continue;
37             }            
38             stack.input(i1);
39         }
40         while(stack.top > 0)
41         {
42             System.out.println(stack.getout());
43         }
44 
45     }
46 }
47 
48 
Stack Class
 1 
 2 public class Stack implements Access
 3 {
 4     private int array[] = new int[80];
 5     
 6     int top = 0;
 7 
 8     public void input(int i)
 9     {
10         array[top++] = i;
11     }
12     public int getout()
13     {
14         return array[--top];
15     }
16 }
17 
  
芳儿宝贝.我爱你