Java List to Long Number Array toLongArray(final List idList)

Here you can find the source of toLongArray(final List idList)

Description

to Long Array

License

LGPL

Declaration

public static long[] toLongArray(final List<String> idList) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.util.*;

public class Main {
    public static long[] toLongArray(final List<String> idList) {
        if (null == idList || idList.isEmpty()) {
            return new long[0];
        }/*from w w w  . j  av  a 2s. c  o  m*/
        long[] result = new long[idList.size()];
        for (int i = 0; i < idList.size(); i++) {
            result[i] = Long.parseLong(idList.get(i));
        }
        return result;
    }

    public static long[] toLongArray(String[] idList) {
        if (null == idList || idList.length == 0) {
            return new long[0];
        }
        long[] result = new long[idList.length];
        for (int i = 0; i < idList.length; i++) {
            result[i] = Long.parseLong(idList[i]);
        }
        return result;
    }
}

Related

  1. toLong(List list)
  2. toLongArray(final List list)
  3. toLongArray(List list)
  4. toLongArray(List list)
  5. toLongArray(List list)
  6. toLongArray(List list)