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?

Était-ce utile?

La solution

Of course, it can.

    Stack<Integer> stack = new Stack<>();
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top