import java.util.Scanner;
public class TestScanner { /** * @param args */ public static void main(String[] args){ //TOOD Auto-generated method stub /*int nextValue; Scanner kpInput = new Scanner(System.in); nextValue = kpInput.nextInt(); System.out.println("读取:" + nextValue); kpInput.close(); 从键盘读取若干整数并读取输出*/ int nextValue, sum = 0; Scanner kpInput = new Scanner(System.in); while(kpInput.hasNextInt()){ nextValue = kpInput.nextInt(); sum += nextValue; System.out.println(nextValue); } kpInput.close(); System.out.println("Sum: " + sum); }
}
转载于:https://www.cnblogs.com/my843532194/p/5331100.html
相关资源:HTML期末大作业