I have a Box class which holds a value and I want to create an array of this class.
Box Class:
public class Box<T> {
public T t;
public Box(T t){ this.t = t; }
}
Test Class:
public class Test {
public static void main(String[] args) {
Box<Integer>[] arr = new Box<Integer>[10];
}
}
Compiler says :
Cannot create a generic array of Box
I wonder that why we cant do that and how can I do that?