标签:
import java.util.Scanner; public class TestScanner { public static void main(String[] args) { int nextValue; int sum = 0; Scanner kbIntput = new Scanner(System.in); kbIntput.useDelimiter("\\s");//设置分隔符 while(kbIntput.hasNextInt()) { nextValue = kbIntput.nextInt(); sum+=nextValue; } kbIntput.close(); System.out.println("Sum:"+sum); } }
标签:
原文地址:http://www.cnblogs.com/Mrsli/p/5329739.html