标签:
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 kpInput = new Scanner(System.in);
kpInput.useDelimiter("\\s");
while(kpInput.hasNextInt()){
nextValue = kpInput.nextInt();
sum+=nextValue;
System.out.println( nextValue);
//System.out.println(kpInput.hasNextInt());
//System.out.println("sum"+sum);
}
kpInput.close();
System.out.printf("sum: %d",sum);
}
}
标签:
原文地址:http://www.cnblogs.com/guaishoubiubiu/p/5367710.html