Collection 与iterator接口
发表于:2007-07-01来源:作者:点击数:
标签:
import java .util.*; /** * Collection 与iterator接口 * * **/ public class TestCollection { nbsppublic static void main(String args[]) nbsp{ nbspnbsp ArrayList v = new ArrayList(); nbspnbspint b = 0; nbspnbspSystem.out.println("please input
import
java.util.*;
/**
* 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);     }
}
原文转自:http://www.ltesting.net