There are two bugs:
First: The class defines a type T, and second the Method defines it own type T, but both T's hase nothing to do with each other. -- So you have to remove the extra Type T from the methods declaration:
public RegisterSet(int size) {
instead of:
public <T> RegisterSet(int size) {
Second: The method Array.newInstance requires an instance of Class as its first parameter, but the type T is not an instance of class. - What you need is to intoduce an new parameter of type Class to you constructor argument list, and use this parameter for array creation.
At least all together should look like:
import java.lang.reflect.Array;
public class RegisterSet<T> {
private T[] register;
public RegisterSet(int size, Class<T> clazz) {
@SuppressWarnings("unchecked")
T[] register = (T[]) Array.newInstance(clazz, size);
}
}
...
new RegisterSet<Integer>(5, Integer.class)