기본 질문과 같지만 실제로 혼란 스럽습니다. 나는 그래프의 인접성리스트를 표현하려한다.목록 배열 표현하기
public class Graph
{
private final int V;
private List<Integer>[] adj;
public Graph(int V)
{
this.V = V;
this.adj = (List<Integer>[]) new LinkedList[V]; // this works
}
}
질문 1 : 나는이 개 질문이 내가 아래를 수행 할 때, 그것은
Array type expected; found: 'java.util.LinkedList<java.lang.Integer>'
this.adj = (List<Integer>[]) new LinkedList<Integer>()[V];
내가 바로, 정수 배열의 목록을 만드는 오전 없다는 오류를 준다?
질문 2는 :
this.adj = (List<Integer>[]) new LinkedList<Integer>[V];
마지막 두 가지 접근 방식의 문제는 무엇인가 :이 작업을 수행 할 때, 다시 일반적인 배열 생성을 말하는 오류를 준다? 나는 첫번째 것이 더 정확하다고 생각한다.
어떤 유형이'this.adj'입니까? – FlyingPiMonster
개인 목록 [] adj; –
OneMoreError