Java List from Array arrayToList(T[] source)

Here you can find the source of arrayToList(T[] source)

Description

Convert the supplied array into a List.

License

Open Source License

Parameter

Parameter Description
T the type of elements of the list
source the array

Return

the converted List result

Declaration

public static <T> List<T> arrayToList(T[] source) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2008, 2010 VMware Inc./*from   www .  ja  va2 s .  c om*/
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   VMware Inc. - initial contribution
 *******************************************************************************/

import java.util.Arrays;

import java.util.List;

public class Main {
    /**
     * Convert the supplied array into a List. 
     * <p>A <code>null</code> source value will be converted to an
     * empty List.
     * @param <T> the type of elements of the list
     * @param source the array
     * @return the converted List result
     * @see ObjectUtils#toObjectArray(Object)
     */
    public static <T> List<T> arrayToList(T[] source) {
        return Arrays.asList(source);
    }
}

Related

  1. arrayToList(T[] array)
  2. arrayToList(T[] array)
  3. arrayToList(T[] array)
  4. arrayToList(T[] array)
  5. arrayToList(T[] obj, List newList)
  6. arrayToListWithUpperCase(String[] arrValues)
  7. arrayToString(List arr)
  8. arrayToStringList(Object array)
  9. asList()