我在创建队列对象时遇到问题。我不知道出了什么问题。
我的代码:
import java.util.*;
public class Demo {
public static void main(String[] args) {
Queue<Integer> q = new LinkedList<Integer>();
}
}
编译器错误:
Exception in thread "main" java.lang.Error: Unresolved compilation problem: The type LinkedList is not generic; it cannot be parameterized with arguments
最佳答案
可能是名称冲突(查看默认包中是否有名为 LinkedList 的类)
试试这个 -
Queue<Integer> q = new java.util.LinkedList<Integer>();
关于java - 从 LinkedList 创建队列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16003559/