Java tutorial
//package com.java2s; import java.util.Arrays; import java.util.List; import com.google.common.base.Function; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; public class Main { public static Function<String, Long> PARSE_LONG_FUNCTION = new Function<String, Long>() { public Long apply(String from) { return Long.valueOf(from); } }; public static long[] toLongArray(Iterable<String> strings) { List<Long> list = toLongList(strings); long[] array = new long[list.size()]; for (int i = 0; i < array.length; i++) { array[i] = list.get(i); } return array; } public static long[] toLongArray(String... strings) { long[] longs = new long[strings.length]; for (int i = 0; i < longs.length; i++) { longs[i] = Long.parseLong(strings[i]); } return longs; } public static List<Long> toLongList(Iterable<String> strings) { return Lists.newArrayList(Iterables.transform(strings, PARSE_LONG_FUNCTION)); } public static List<Long> toLongList(String... strings) { return toLongList(Arrays.asList(strings)); } }