Your problem is that you create an array Objectin your method concat.
Instead
T[] concatenatedArray = (T[]) new Object[size];
use
T[] concatenatedArray = (T[]) Array.newInstance(arrays[0].getClass()
.getComponentType(), size);
UPDATE: While the above will probably do the job for you, newacct pointed out in the comments that it is even better / safer to use
T[] concatenatedArray = (T[]) Array.newInstance(arrays.getClass()
.getComponentType().getComponentType(), size);
, . ArrayUtils.concat(new String[]{"foo"}, new Integer[]{42}); ( ), ArrayStoreException.
, , T, , .
, .
public static <T> T[] concat(T[] array1, T[]... arrays);
: , java, . https://docs.oracle.com/javase/tutorial/java/generics/genMethods.html.
concat ( Object[] Integer[]), - - Object[] ( , ).
, , Integer[] ( ;)), .
, : : , , Apache Commons , . , - ;)