// more on using ListNode class ListNodeDemo1 { public static void main(String[] args) { // Ex1: Write the statement to creat the one-node list: x -> "UVA"? ListNode x = new ListNode("UVA", null); // Ex2: Create a node y, with "VWU" that points to that last node x? ListNode y = new ListNode("VWU", x); // Ex3: x.getData() = ? // "UVA" // System.out.println(x.getData()); // Ex4: y = y.getLink(); // y.getData() = ? // "UVA" // System.out.println(y.getData()); // Ex5: create a new node, z, with "Harvard", and then append it to the last node // to the above list ListNode z = new ListNode("Harvard", null); x.setLink(z); //System.out.println(x.getData() + " " + x.getLink().getData()); // Ex6: x = x.getLink(); // x.getData() = ? // "Harvard" System.out.println(x.getData()); } }