import org.junit.Test;spa
public class Tool {.net
/*public static int add(int a , int b){get
return a+b;it
}class
public static int add(int a , int b,int c){import
return a+b+c;bug
}im
public static int add(int a , int b,int c,int d){static
return a+b+c+d;junit
}
public static int add(int[] arr){
int result = 0;
for(int a : arr){
result+=a;
}
return result;
}*/
//定義
public static int add(int... arr){
int result = 0;
for(int a : arr){
result+=a;
}
return result;
}
//調用
public void fun1(){
System.out.println(Tool.add(1,2,3,4,5));
System.out.println(Tool.add(1,2));
System.out.println(Tool.add());
System.out.println(Tool.add(null));
}
}