Java List to Primitive Array toPrimitivebyList(List list)

Here you can find the source of toPrimitivebyList(List list)

Description

to Primitiveby List

License

Open Source License

Declaration

public static long[] toPrimitivebyList(List<Long> list) 

Method Source Code


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

import java.util.List;

public class Main {
    public static long[] toPrimitivebyList(List<Long> list) {
        int nullcounter = 0;
        for (Long l : list) {
            if (l == null) {
                nullcounter++;//from   w  w w.j a va2s  .  co  m
            }
        }
        long[] result = new long[list.size() - nullcounter];
        nullcounter = 0;
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i) == null) {
                nullcounter++;
            } else {
                result[i - nullcounter] = list.get(i);
            }
        }
        return result;
    }
}

Related

  1. toPrimitiveArray(List array)
  2. toPrimitiveArray(List input)
  3. toPrimitiveArray(List list)
  4. toPrimitiveArray(List target_)
  5. toPrimitiveDouble(List values)
  6. toPrimitiveIntArray(List temp)
  7. toPrimitiveIntArray(List values)
  8. toPrimitiveIntegerArray(List listOfInt)