Java List from Array array2List(Object[] obj)

Here you can find the source of array2List(Object[] obj)

Description

Converts an Object[] to a List.

License

Open Source License

Parameter

Parameter Description
obj Array of objects to be placed in List

Return

List of objects

Declaration

public static List array2List(Object[] obj) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

import java.util.List;

public class Main {
    /**//  w w w .j  a  v a  2s .  c o  m
     * Converts an Object[] to a List. If null Object[] is provided, an empty
     * List is returned.
     * 
     * @param obj
     *            Array of objects to be placed in List
     * @return List of objects
     */
    public static List array2List(Object[] obj) {
        ArrayList list = new ArrayList();
        if (obj != null) {
            for (int i = 0; i < obj.length; i++) {
                list.add(obj[i]);
            }
        }
        return (list);
    }
}

Related

  1. array2ArrayList(final T[] array)
  2. array2list(String[] array)
  3. array2List(T... array)
  4. arrayAsArrayList(E... elements)
  5. arrayAsList(Object value)