Java Array to ArrayList toArrayList(Object pObject)

Here you can find the source of toArrayList(Object pObject)

Description

to Array List

License

Open Source License

Declaration

public static final List toArrayList(Object pObject) 

Method Source Code

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

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static final List toArrayList(Object pObject) {
        List array;//ww  w  .j  a  v  a2  s  .c om

        // Catch null object
        if (pObject == null) {
            array = new ArrayList(1);
        }

        // Catch single String passed (Servlet parameter bug workaround)
        else if (pObject instanceof String) {
            array = new ArrayList(1);
            array.add(pObject);
        }

        // Process normal string array (Documented servlet processing)
        else {
            String[] lObjectArray = (String[]) pObject;
            array = new ArrayList(lObjectArray.length);
            for (int i = 0; i < lObjectArray.length; i++) {
                array.add(lObjectArray[i]);
            }
        }
        return array;
    }
}

Related

  1. toArrayList(double[] dd)
  2. toArrayList(final T... array)
  3. toArrayList(int[] p)
  4. toArrayList(int[] values)
  5. toArrayList(List list)
  6. toArrayList(String str)
  7. toArrayList(String[] ss)
  8. toArrayList(T... items)
  9. toArrayList(T[] vals)