// Simple client to interact with ListNode. public class ListNodeClient { public static void main(String[] args) { ListNode front = new ListNode(10); front.next = new ListNode(20); front.next.next = new ListNode(30); // Hardcoded to print out this 3 element list // System.out.println(front.data); // System.out.println(front.next.data); // System.out.println(front.next.next.data); // Standard traversal for a linked list // start at the front ListNode current = front; while (current != null) { // loop until the end // do something with the data System.out.println(current.data); // move to the next current = current.next; } } }