第三周JAVA学习

import java.util.Scanner;

public class testscanner {

public static void main(String[] args) {

int nextValue;

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

}

}

posted @ 2016-03-28 20:42  2014330112李杰  阅读(119)  评论(0编辑  收藏  举报