
1 public class GetSum {
2 public static void main(String[] args) {
3 int S = 0;
4 for(String i:args)
5 S += Integer.parseInt(i);
6 System.out.print("Sum = " + S);
7 }
8 }

关键点:
调用Integer静态方法parseInt(String)将字符串解析为int。
原文:http://www.cnblogs.com/lzq666/p/7630329.html