내가이 패키지에이 노드를 정의 :중첩 클래스에서 가져온 패키지를 사용할 수없는 이유는 무엇입니까?
import provided.Node;
class LinkedList {
private Node head;
head.getNext(); // there is no error here, the method getNext() is available
class LinkedListIterator <Node> implements Iterator<Node> {
private Node next_node;
public Node next(){
return next_node.getNext(); // The method getNext() is
// undefined for the type Node
}
}
}
전체 오류를 제공 할 수 있습니까? 이 코드에 다른 문제가 있습니다 : LinkedListIterator.next() delcares는 Node를 리턴하고, next_node.getNext()는 Integer를 리턴합니다. – amit
코드 예는 지저분한 것입니다. 나는 그 문제가 getNext()가 Node를 반환하지 않을 것이라고 생각한다. 나는 정의되지 않았다. –
'next' 서명에''Public'' 값이 있습니다. 그것은 바로 오류입니다. 먼저 문제를 해결하고 다음 문제로 넘어갑니다. –