Java Array to ArrayList arrayToArrayList(Object[] array)

Here you can find the source of arrayToArrayList(Object[] array)

Description

Convert array into list

License

BSD License

Parameter

Parameter Description
array An array

Return

A list containing contents of array

Declaration

public static ArrayList arrayToArrayList(Object[] array) 

Method Source Code


//package com.java2s;
/*L/*from  www .  j av a2  s.c o m*/
 *  Copyright RTI International
 *
 *  Distributed under the OSI-approved BSD 3-Clause License.
 *  See http://ncip.github.com/webgenome/LICENSE.txt for details.
 */

import java.util.ArrayList;

public class Main {
    /**
     * Convert array into list
     * @param array An array
     * @return A list containing contents of array
     */
    public static ArrayList arrayToArrayList(Object[] array) {
        ArrayList list = new ArrayList();
        if (array != null)
            for (int i = 0; i < array.length; i++)
                list.add(array[i]);
        return list;
    }
}

Related

  1. arrayToArrayList(Object aobj[])
  2. arrayToArrayList(Object[] myArray)
  3. arrayToArraylist(String[] array)
  4. arrayToArrayList(T[] array)
  5. arrayToArraylist(T[] array)