Arrays are objects, but their type is defined by the type of the contained objects. Therefore, one cannot just cast A[] to T[], but each A member of the specific A[] must be cast to a T object. Generic example:
public static <T, A> T[] castArray(T[] target, A[] array) {
for (int i = 0; i...