Here is my code:
package datastructures; import java.util.Iterator; public class Stack{ private class Node{ T data; N
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.
Node
T
Stack
Remove declaration of type parameter in your Node type (that's probably what you mean for it)