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);

}

}

posted @ 2016-03-28 19:53  软三2014330331郑剑宏  阅读(160)  评论(0编辑  收藏  举报