package holding;
import java.util.Arrays;
public class csdn1 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String names[] = { "Georgianna", "Tenn", "Simon", "Tom" };
System.out.println(Arrays.asList(names));
System.out.println(Arrays.asList(new String[]{"Georgianna", "Tenn", "Simon", "Tom"}));
System.out.println(Arrays.asList(new Integer[]{1,2,3}));
System.out.println(Arrays.asList(new int[]{1,2,3}));
}
}
[Georgianna, Tenn, Simon, Tom]
[Georgianna, Tenn, Simon, Tom]
[1, 2, 3]
[[I@1a62c31]
------解决思路----------------------
static <T> List<T> asList(T... a)
Returns a fixed-size list backed by the specified array.
这个是asList方法的方法签名!接受的参数为可变参数!因为new Integer[]{1,2,3}是一个对象数组所以asList()方法认为数组中有三个元素。但new int[]{1,2,3}是基本类型的数组,asList(T... a) 方法将整个数组对象看成一个元素!并没有将里面的元素当成一个元素,
所以第二个只打印出一个数组对象地址!