Arrays { public static <A> A[] cons(Class<A> type, A a, A[] as) { @SuppressWarnings("unchecked") final A[] x = (A[]) Array.newInstance(type, as.length + 1); x[0] = a; System.arraycopy(as, 0, x, 1, as.length); return x; } private  Arrays(); static A[] cons(Class<A> type, A a, A[] as); static A[] append(Class<A> type, A[] as, A a); static A[] array(A... as); static Function<A, A[]> singleton(final Class<A> type); static String mkString(A[] as, String sep);  }
@Test public void testCons() { final Ax<String>[] as = cons(Ax.class, new Ax<String>(), Arrays.array(new Bx<String>())); assertEquals(2, as.length); }