I am trying to build a generic array but in reverse so for example if [2,3,4,5] was removed from the original array would return [5,4,3,2]. My issue is my code is not doing that. How do you do this with a generic? Here is my attempt.
public E[] removeNItems(int n) {
    E[] a = newArray(n);
    if (n > size) {
        return null;
    } else {
        size=size-n;
        int j=0;
        for (int i = size; i <= n; i++) {
            a[j] = stack[i];
            stack[i] = null;
            j++;
        }
    }
    return a;
}
