[英]Implementing Graph in Java, getting raw type error
I'm trying to implement a Graph as an adjacency list, with the code below. 我正在尝试使用下面的代码将Graph实现为邻接表。 I'm getting a raw type error on line 9.
我在第9行遇到原始类型错误。
Edit: Just want to clarify, I get an unchecked/unsafe operation error, then when I compile with Xlint, I get the raw type error. 编辑:只是想澄清一下,我得到一个未经检查/不安全的操作错误,然后当我用Xlint编译时,我得到了原始类型错误。
import java.util.LinkedList;
public class AdjListGraph{
private int vertices;
private LinkedList<Integer>[] AdjList;
public AdjListGraph(int v){
this.vertices = v;
AdjList = (LinkedList<Integer>[]) new LinkedList[v];
for (int i = 0; i < v; i++){
AdjList[i] = new LinkedList<Integer>();
}
}
LinkedList<Integer>[]
is a bad smell. LinkedList<Integer>[]
有异味。 And that's the real problem.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.