asList(T... 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 {@link RandomAccess}.
     *
     * 

This method also provides a convenient way to create a fixed-size * list initialized to contain several elements: *

     *     List stooges = Arrays.asList("Larry", "Moe", "Curly");
     * 
* * @param a the array by which the list will be backed. * @return a list view of the specified array. * @see Collection#toArray() */ public static List asList(T... a) { return new ArrayList(a); } 从上面的说明中可以发现,他返回的是一个固定大小的list,所以后面如果你进行添加元素的操作时,他就会报unSupport Operation异常。

 

你可能感兴趣的:(java,源码分析)