나는군요 호환되지 않는 유형 : T는 형태 변수입니다 개체 T로 변환 할 수 없습니다 : T는 개체 클래스 스택에 선언 확장합니다.
도움을 주시겠습니까? 왜 그런지 모르겠습니다. 메소드 pop ()과 getData ()는 동일한 유형 T입니다.
여기에 단축 코드가 있습니다.
public class Stack<T> {
Node head;
public T pop() {
return head.getData(); //the error is on this line
}
private class Node <T> {
private final T data;
private Node next;
private Node(T data, Node next) {
this.data=data;
this.next=next;
}
private T getData() {
return data;
}
}
}
이어야합니다 Node<T> head
. 유형 매개 변수를 추가하는 것을 잊었습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다