Convert the specified array to a list which contains all elements in the array - Android java.util

Android examples for java.util:List Convert

Description

Convert the specified array to a list which contains all elements in the array

Demo Code


import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import com.elminster.common.util.Messages.Message;

public class Main{
    public static void main(String[] argv){
        Object array = "book2s.com";
        System.out.println(array2List(array));
    }//ww w  . ja  v  a 2s .c  o m
    /**
     * Convert the specified array to a list which contains all elements in the
     * array
     * 
     * @param array
     *          the specified array
     * @return a list which contains all elements in the array
     */
    public static List<?> array2List(Object array) {
        return Arrays.asList(ObjectUtil.toObjectArray(array));
    }
}

Related Tutorials