int [] a1 = new int[]{1,2,3};
System.out.println("a1 is "+Arrays.asList(a1)); ===>call java 1.4
Integer [] a11= new Integer[]{1,2,3};
System.out.println("a1 is "+Arrays.asList(a1)); ===>call java 1.4
Integer [] a11= new Integer[]{1,2,3};
System.out.println("a11 is "+Arrays.asList(a11)); ===>call java 1.6
a1 is [[I@c17164]
a11 is [1, 2, 3]
java 1.6
asList
public static <T> List<T> asList(T... a)
-
返回一个受指定数组支持的固定大小的列表。(对返回列表的更改会“直接写”到数组。)此方法同
Collection.toArray()
一起,充当了基于数组的 API 与基于 collection 的 API 之间的桥梁。返回的列表是可序列化的,并且实现了RandomAccess
。此方法还提供了一个创建固定长度的列表的便捷方法,该列表被初始化为包含多个元素:
List<String> stooges = Arrays.asList("Larry", "Moe", "Curly");
-
-
参数:
-
a
- 支持列表的数组。
返回:
- 指定数组的列表视图。
-
java 1.4
asList
public static List asList(Object[] a)
-
Returns a fixed-size list backed by the specified array. (Changes to the returned list "write through" to the array.) This method acts as bridge between array-based and collection-based APIs, in combination with
Collection.toArray. The returned list is serializable and implements
RandomAccess
. -
-
Parameters:
-
a
- the array by which the list will be backed.
Returns:
- a list view of the specified array. See Also:
-
Collection.toArray()
-