// Let's use the command line to add some numbers. public class Add { public static void main(String [] args) { // For each number in the command line, let's add it to the total. int sum = 0; for (int i = 0; i < args.length; ++i) { try { sum += Integer.parseInt(args[i]); } catch(NumberFormatException e) { continue; } } System.out.printf("The sum of the integers is %d\n", sum); } } // When I first typed the program, I was in a hurry and I typed // args[0] instead of args[i], so the program said the sum of 7,2,6,-3 // 28 because it was adding 7 four times.