incompatible types : java.lang.Object cannot be converted to T

前端 未结 4 1999
心在旅途
心在旅途 2021-01-14 15:57

Here is my code:

package datastructures;

import java.util.Iterator;

public class Stack{
    private class Node{
        T data;
        N         


        
4条回答
  •  孤独总比滥情好
    2021-01-14 17:02

    You are declaring Node inner type with its own type parameter, so T of Node shadows T of Stack, and they are essentially different types.

    Remove declaration of type parameter in your Node type (that's probably what you mean for it)

提交回复
热议问题