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 <tt>Collection.toArray</tt>.  The returned list is
     * serializable and implements {@link RandomAccess}.
     *
     * <p>This method also provides a convenient way to create a fixed-size
     * list initialized to contain several elements:
     * <pre>
     *     List<String> stooges = Arrays.asList("Larry", "Moe", "Curly");
     * </pre>
     *
     * @param a the array by which the list will be backed.
     * @return a list view of the specified array.
     * @see Collection#toArray()
     */
    public static <T> List<T> asList(T... a) {
	    return new ArrayList<T>(a);
    }

从上面的说明中可以发现,他返回的是一个固定大小的list,所以后面如果你进行添加元素的操作时,他就会报unSupport Operation异常。

猜你喜欢

转载自woyixiaorenne.iteye.com/blog/2288838