-2
Type mismatch: cannot convert from MyLinkedList.Node<Type> to MyLinkedList.Node<Type>
에서 모두 말한다 Eclipse에서 이상한 유형 불일치 오류가 점점 오전과 동일 할 수 있습니다. 스틸 유형 불일치? :(
코드 :이 캐스트 적용하는 경우
import java.util.Iterator;
public class MyLinkedList<Type> implements Iterable<Type> {
private Node<Type> head;
// default contructor initializes the null list
public MyLinkedList(){
head = null;
}
// Static Inner Node Class
private static class Node<Type>{
private Type data;
private Node<Type> next;
public Node(Type dataValue, Node<Type> nextNode){
this.data = dataValue;
this.next = nextNode;
}
}
@Override
public Iterator<Type> iterator() {
// TODO Auto-generated method stub
return null;
}
private class LinkedListIterator<Type>{
private Node<Type> nextNode;
public LinkedListIterator(){
///////////////////////////////// ERROR ///////////////////////////
nextNode = head;
}
}
}
오류가 도망 간다 :.
nextNode = (Node<Type>) head;
'유형'이라는 클래스가 있습니까? – pennstatephil
실제 코드를 알려주십시오. Generics는 까다 롭기 때문에 코드 없이는 오류를 구분하기가 어렵습니다. –
당신의'Type' 클래스 참조가 다릅니다. 한 패키지에는'Type'이 있고 다른 패키지에는'Type' 클래스가 있습니다. –