Here is my code:
package datastructures; import java.util.Iterator; public class Stack{ private class Node{ T data; N
(For Java 8) You can use a typed variable with the diamond operator:
private Node newNode(T data) { Node new_node = new Node<>(); new_node.data = data; new_node.next = null; return new_node; }
Otherwise the generic is initalized as Object and therefore the error is shown.
Object