Convert List<Long> to long Array as long[] - Android java.lang

Android examples for java.lang:array convert

Description

Convert List<Long> to long Array as long[]

Demo Code

import android.util.SparseArray;
import java.util.ArrayList;
import java.util.List;

public class Main{

    public static long[] toLongArray(List<Long> list) {
        if (list == null || list.isEmpty())
            return null;
        long[] arr = new long[list.size()];
        for (int i = 0; i < list.size(); i++) {
            arr[i] = list.get(i).longValue();
        }/*www  . j  a  v a  2  s . c  om*/
        return arr;
    }

}

Related Tutorials