用java編寫計算整數之和的方法?
public class Varargs { public static void main(String[] args) { // TODO Auto-generated method stub int s = test(1,2,3,4); System.out.println(s); } public static int test(int... a ) { int sum=0; for(int tmp : a) { sum+=tmp; } return sum; }}