JAVA学习笔记(三)
package javazuoye;
import java.util.Scanner;
public class summation {
public static void main(String[] args) {
int nextValue;
int sum = 0;
Scanner r1 = new Scanner(System.in);
r1.useDelimiter("\s");
while (r1.hasNextInt()) {
nextValue = r1.nextInt();
sum += nextValue;
}
System.out.println("Sum:" + sum);
}
}