Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.Collection; import java.util.List; import java.util.Map; public class Main { /** * Converts the given list of Double objects into an array of primitive doubles. * * If the list is null or empty, an empty array will be returned * * @param inputList List of Double object to be converted in a primitive array * @return */ public static double[] listToPrimitiveArray(List<Double> inputList) { if (isEmpty(inputList)) { return new double[0]; } else { return inputList.stream().mapToDouble(Double::new).toArray(); } } /** * Return true if this map is null or it's empty. * * @param map * @return */ public static boolean isEmpty(Map<? extends Object, ? extends Object> map) { return map == null || map.size() == 0; } public static boolean isEmpty(Collection<? extends Object> list) { return list == null || list.isEmpty(); } }