java第三次作业
import java.util.Scanner;
public class Wangbo {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int nextValue,sum = 0;
Scanner sr = new Scanner(System.in);
sr.useDelimiter("\\s");
while(sr.hasNextInt()){
nextValue = sr.nextInt();
sum += nextValue;
}
System.out.println("Sum = "+sum);
public class Wangbo {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int nextValue,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();
}
}![](https://images2015.cnblogs.com/blog/906589/201603/906589-20160330125523098-150669708.png)
}
}
![](https://images2015.cnblogs.com/blog/906589/201603/906589-20160330125523098-150669708.png)