提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
从参数读取的整数值总和
public class Adder { public static void main(String[] args) { int numArgs = args.length; /** nowjava - 时 代 Java 提 供 **/ //this program requires at least two arguments on the command line if (numArgs < 2) { System.out .println("This program requires two command-line arguments."); } else { int sum = 0; for (int i = 0; i < numArgs; i++) { sum += Integer.valueOf(args[i]).intValue(); } //print the sum System.out.println(sum);/**来 自 nowjava - 时 代 Java**/ } } }