实例:
package cn.itcast.demo;
import java.util.Arrays;
import java.util.List;
import org.junit.Test;
public class Demo4 {
@Test
public void testSum() {
sum(1, 2, 3, 4, 5, 6);
}
public void sum(int... nums) {
int sum = 0;
for (int i : nums) {
sum += i;
}
System.out.println(sum);
}
@Test
public void testAa() {
sum(1, 2, 3, 4, 5, 6);
}
public void aa(int x, int... nums) {
}
@Test
public void bb() {
List list = Arrays.asList("1", "2", "3");
System.out.println(list);
String arr[] = { "1", "2", "3", "4" };
list = Arrays.asList(arr);
System.out.println(list);
Integer nums[] = { 1, 2, 3, 5 };
list = Arrays.asList(nums);
System.out.println(list);
}
}