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?

有帮助吗?

解决方案

Of course, it can.

    Stack<Integer> stack = new Stack<>();
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top