There is a very useful Arrays.asList() :
public static <T> List<T> asList(T... a) { return new ArrayList<T>(a); }
But no Arrays.array() :
public static <T> T[] array(T... values) { return values; }
Being completely trivial, this would be a convenient way to build arrays:
String[] strings1 = array("1", "1", "2", "3", "5", "8"); // as opposed to the slightly more verbose String[] strings2 = new String[] { "1", "1", "2", "3", "5", "8" }; // Of course, you can assign array literals like this String[] strings3 = { "1", "1", "2", "3", "5", "8" }; // But you can't pass array literals to methods: void x(String[] args); // doesn't work x({ "1", "1", "2", "3", "5", "8" }); // this would x(array("1", "1", "2", "3", "5", "8"));
Is there such a method somewhere else in the Java language, outside of java.util.Arrays ?