Java.集合类.Collection.ArrayList.Iterator

Java.集合类.Collection.ArrayList.Iterator_第1张图片

 

 

import java.util.*; class TestCollection { public static void main(String [] args) { int b=0; ArrayList v=new ArrayList(); // System.out.print("Please enter numbers:"); while(true) { try { b=System.in.read(); } catch(Exception e) { System.out.println(e.getMessage()); } 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); } }

你可能感兴趣的:(exception,String,Integer,iterator,import,Numbers)