に変換することはできませんが、私のコードです:互換性のない型:java.lang.Objectのは、T
Error: incompatible types : java.lang.Object cannot be converted to T
I:私はpopメソッドでエラーが出ます
package datastructures;
import java.util.Iterator;
public class Stack<T>{
private class Node<T>{
T data;
Node next;
}
private int size;
private Node head;
private Node newNode(T data){
Node new_node = new Node();
new_node.data = data;
new_node.next = null;
return new_node;
}
public Stack(){
size = 0;
head = null;
}
public T pop() {
if(head == null)
return null;
T ret_val = head.data; //Error here
head = head.next;
this.size--;
return ret_val;
}
}
、ここでエラーですこのエラーを理解していない、私はコード内の任意の場所にオブジェクトを使用していない。