www.baidu.com

          JavaCode--我愛你,芳兒

          JavaStudy--我愛你,芳兒

          關于模擬堆棧的java程序

          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 


           

          芳兒寶貝.我愛你

          posted on 2007-12-04 23:03 wǒ愛伱--咾婆 閱讀(263) 評論(0)  編輯  收藏 所屬分類: JavaCode

          導航

          統計

          公告

          芳兒寶貝.我愛你


          黑客基地
          http://www.hackbase.com
          全球最大的黑客門戶網站


           最近在讀的書:

          常用鏈接

          留言簿(1)

          隨筆分類(37)

          JavaCode

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 盐山县| 新宾| 库伦旗| 翼城县| 浦县| 马边| 金昌市| 收藏| 合肥市| 灌云县| 苏尼特右旗| 东光县| 余庆县| 隆尧县| 娱乐| 垫江县| 文安县| 稻城县| 抚顺市| 西充县| 滦平县| 化州市| 巴彦淖尔市| 水城县| 任丘市| 新密市| 钦州市| 贡觉县| 米泉市| 汾西县| 上犹县| 安仁县| 绩溪县| 虞城县| 武城县| 闽侯县| 深泽县| 股票| 巴南区| 金乡县| 玉山县|