I was writing a stack, one with a static Node and other non-static.
public class Stack implements Iterable
{
private int N;
private
It's warning you that you are using the generic argument name E
in a scope when it already is defined. Changing the generic argument name for Node
would be one way to resolve the warning:
public class Stack implements Iterable
{
private int N;
private Node first;
private class Node
{
private T item;
private Node next;
}
}
But since E is already exists, you should just use that; Node
is already generic due to being defined within a generic type (Stack
and Stack
are different types):
public class Stack implements Iterable
{
private int N;
private Node first;
private class Node
{
private E item;
private Node next;
}
}
Note that this works because Node
is not static, therefore it has a reference to the outer Stack
object, and because of this E
must be defined. If Node
is static then it has no real relationship to the outer Stack
type other than effectively being within its lexical scope.