public class Node{ Node next; int data; public Node(int data){ this.data = data; } public void setNext(Node newNode){ next = newNode; } public Node getNext(){ return next; } public int getData(){ return data; } public static void main(String[] args) { Node en = new Node(1); Node to = new Node(2); Node tre = new Node(4); en.setNext(to); to.setNext(tre); System.out.println(tre.next.getNext()); } }