Question

Stack is a generic class in Java, it definition is class Stack<E> extends Vector<E>, but why I cannot instantiate it with type parameter like Stack<Integer> s = new Stack<>(); But a Vector can?

Was it helpful?

Solution

Of course, it can.

    Stack<Integer> stack = new Stack<>();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top