Convert Int Array int[] to List<Integer> - Android java.util

Android examples for java.util:List Convert

Description

Convert Int Array int[] to List<Integer>

Demo Code

import android.text.TextUtils;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Array;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{

    /**/*from ww  w .  j  av  a  2 s.  c o  m*/
     * Gets the list from Integer array.
     *
     * @param array the array
     * @return the list from Integer array
     */
    public static List<Integer> getListFromIntArray(int array[]) {
        if (array == null || array.length == 0) {
            return null;
        }
        List<Integer> list = new ArrayList<Integer>();
        int length = array.length;
        for (int i = 0; i < length; i++) {
            list.add(array[i]);
        }
        return list;
    }

}

Related Tutorials