Design ideas
After running the configuration input number, it is a string type, with Integer.valueof (ARG), and after the conversion, it is added by the for loop and assigned to sum and then printed out.
Program Flowchart
Program source Code
20163510 Zhang Yunxi public class Add {/** * @param args */public static void main (string[] args) {//TODO auto-generated method s Tubint sum=0;//defines sum as the last and value, initialized to 0 System.out.println ("Number of digits:" +args.length);//Calculate input length and output for (String Arg:args) {sum= Sum+integer.valueof (ARG);//convert string type to int type and add} System.out.println ("sum=" +sum);//Output Last value}}
Experiment
Imitate the Javaapparguments.java example, write a program that receives multiple numbers from the command line, and then outputs the result after summing.