Java Array to List toList(E... values)

Here you can find the source of toList(E... values)

Description

Create List

License

Open Source License

Parameter

Parameter Description
values a parameter

Declaration

public static final <E> List<E> toList(E... values) 

Method Source Code

//package com.java2s;
/*//  ww w .  j a v  a  2s. co m
 * Copyright (C) 2009-2015 SM2 SOFTWARE & SERVICES MANAGEMENT
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program has been created in the hope that it will be useful.
 * It is distributed WITHOUT ANY WARRANTY of any Kind,
 * without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/.
 *
 * For more information, please contact SM2 Software & Services Management.
 * Mail: info@talaia-openppm.com
 * Web: http://www.talaia-openppm.com
 *
 * Module: core
 * File: DataUtil.java
 * Create User: javier.hernandez
 * Create Date: 15/03/2015 12:52:58
 */

import java.util.ArrayList;

import java.util.List;

public class Main {
    /**
     * Create List
     * @param values
     * @return
     */
    public static final <E> List<E> toList(E... values) {

        List<E> list = null;

        if (values != null && values.length > 0) {

            list = new ArrayList<E>(values.length);

            for (E obj : values) {
                list.add(obj);
            }
        }
        return list;
    }
}

Related

  1. toList(byte[] array)
  2. toList(byte[] array)
  3. toList(double[] array)
  4. toList(double[] array)
  5. toList(E... e)
  6. toList(E[] array, int fromIndex, int toIndex)
  7. toList(final double[] array)
  8. toList(final E[] array)
  9. toList(final float[] array)