import java.util.Scanner;
public class TestScanner {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int nextValue,sum = 0;
Scanner sr = new Scanner(System.in);
sr.useDelimiter("\\s");
while(sr.hasNextInt()){
nextValue = sr.nextInt();
sum += nextValue;
}
System.out.println("Sum = "+sum);
sr.close();
}
}
第三次作业
原文:http://www.cnblogs.com/chenhaotian/p/5336743.html