Java tutorial
//package com.java2s; import java.util.Arrays; public class Main { /** * @param <T> * @param elements * @return a mutable copy of {@code elements}, or {@code null} if * {@code elements} is empty. */ public static <T> T[] arrayOrNull(T... elements) { if (elements.length == 0) return null; return array(elements); } /** * @param <T> * @param elements * @return a mutable copy of {@code elements}. */ public static <T> T[] array(T... elements) { return Arrays.copyOf(elements, elements.length); } }