public class Main{ Node head; static class Node { int data; Node next; Node(int d) {data = d;next=null; } } public void display() { Node n = head; while (n != null) { System.out.print(n.data+"
"); n = n.next; } } public static void main(String[] args) { Main Main = new Main(); Main.head = new Node(10); Node second = new Node(15); Node third = new Node(20); Main.head.next = second; second.next = third; Main.display(); } }