Java List from Array asList(Object[] array)

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

Description

Subtitution for Arrays.asList.

License

Apache License

Parameter

Parameter Description
array - Array of elements converted into list

Declaration

public static List asList(Object[] array) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.ArrayList;
import java.util.List;

public class Main {
    /**/*  ww w.  j a v a 2 s .  c o  m*/
     * Subtitution for Arrays.asList. <br>
     * This implementation return an editable list (sizable) an non thread-safe
     * @param array - Array of elements converted into list
     */
    public static List asList(Object[] array) {
        ArrayList list = new ArrayList();

        appendArrayToList(array, list);

        return list;
    }

    /**
     * Append the array's elements into the existing list.
     * @param array - Array of elements to be appended into the list
     * @param list - The target list
     */
    public static void appendArrayToList(Object[] array, List list) {
        for (int i = 0; i < array.length; i++) {
            list.add(array[i]);
        }
    }
}

Related

  1. asList(Object info)
  2. asList(Object o, Class cls)
  3. asList(Object theone)
  4. asList(Object value)
  5. asList(Object value)
  6. asList(Object[] array)
  7. asList(Set set)
  8. asList(String data)
  9. asList(String str)