// LinkedList2.java class Node { public int data; public Node next; } public class LinkedList2 { public static void print(Node head) { Node current = head; while (current != null) { System.out.println(current.data); current = current.next; } } public static void main(String args[]) { // make 5 nodes for the list Node a = new Node(); Node b = new Node(); Node c = new Node(); Node d = new Node(); Node e = new Node(); // set up the data a.data = 10; b.data = 20; c.data = 30; d.data = 40; e.data = 50; // set up the links a.next = b; b.next = c; c.next = d; d.next = e; e.next = null; // print the list print(a); } }