package pro;
import java.util.Scanner;
public class number {
public static void main(String[]args){
//从键盘读取若干整数并求和
int nextValue;
int sum=0;
Scanner num = new Scanner(System.in);
num.useDelimiter("\\s");
while(num.hasNextInt())
{
nextValue = num.nextInt();//读取从键盘输入的数
sum += nextValue;
}
System.out.printf("Sum: %d",sum);
num.close();
}
}
第三次JAVA作业
原文:http://www.cnblogs.com/liuyajuan/p/5329891.html