Java List Create asList(T... objs)

Here you can find the source of asList(T... objs)

Description

Return list literals as list and return array as list; also handle null array.

License

Mozilla Public License

Declaration

public static <T> List<T> asList(T... objs) 

Method Source Code

//package com.java2s;
/******************************************************************************
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0.  If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/.
 * /*  ww  w.  jav a  2s  . c o  m*/
 * Software distributed under the License is distributed on an "AS IS" basis, 
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for 
 * the specific language governing rights and limitations under the License.
 *
 * The Original Code is: FetchMailAtt
 * The Initial Developer of the Original Code is: William Wong (williamw520@gmail.com)
 * Portions created by William Wong are Copyright (C) 2015 William Wong, All Rights Reserved.
 *
 ******************************************************************************/

import java.util.*;

public class Main {
    /** Return list literals as list and return array as list; also handle null array. */
    public static <T> List<T> asList(T... objs) {
        return objs != null ? Arrays.asList(objs) : new ArrayList<T>();
    }
}

Related

  1. asList(Object[] array)
  2. asList(T... a)
  3. asList(T... array)
  4. asList(T... elements)
  5. asList(T... items)
  6. asList(T[] array)
  7. asListBox(double[] a)
  8. asListNoNulls(T... array)
  9. create2DHorizontalIndexList( final int n)