I haven't done much by way of writing my own generic classes, but I'm trying to make my own ArrayStack class and having trouble understanding how to correctly write the constructor.
public class ArrayStack<T> implements List<T> {
private T[] a;
private int n;
public ArrayStack(T[] a) {
this.a = a;
}
}
And my main class that uses it:
public class ArrayStackTester {
public static void main(String[] args) {
ArrayStack<Integer> numbers = new ArrayStack<Integer>();
}
}
This produces a compilation error which says that The ArrayStack<Integer> is undefined
, so I obviously suspect a problem with the constructor in the ArrayStack
class.
I didn't include all the overriden List
methods for brevity.