第三篇学习笔记
求和代码如下:
package sum; import java.util.*; public class sum { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub int nextValue; int sum = 0; Scanner kbInput = new Scanner(System.in); kbInput.useDelimiter("\\s"); while(kbInput.hasNextInt()){ nextValue = kbInput.nextInt(); sum += nextValue; } kbInput.close(); System.out.println("sum = " + sum); } }
结果如下:
posted on 2016-03-28 20:13 软二2014330217吕锦涛 阅读(120) 评论(0) 编辑 收藏 举报