/**
* Collection 与iterator接口
*
*
**/
public class TestCollection
{
   public static void main(String args[])
   {
     ArrayList v = new ArrayList();
     int b = 0;
     System.out.println("please input the number:");
     while(true)
     {
     try
     {
       b = System.in.read();
     }
     catch(Exception e)
     {
         e.printStackTrace();
     }
     if(b=='\r' || b=='\n')
     {
       break;
     }
     else
     {
       int num = b -'0';
       v.add(new Integer(num));
     }
     }
     int sum = 0;
     Iterator e = v.iterator();
     while(e.hasNext())
     {
       Integer intObj = (Integer)e.next();
       sum = intObj.intValue();
     }
     System.out.println(sum);
     }
}
上一篇: Struts 中 Multibox 的用法
下一篇: java小游戏-贪吃蛇
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!



