/* A program demonstrating a simple linked list */ class Element { int data; Element next; } class List { public static void main (String[] args) { // Create 3 elements Element a = new Element(); Element b = new Element(); Element c = new Element(); // Set up a linked list a.data = 10; a.next = b; b.data = 20; b.next = c; c.data = 30; c.next = null; // Print the list Element t = a; while (t != null) { System.out.print (t.data + " "); t = t.next; } } }