class Element { private Object data; private Element next; public Element (Object d, Element link) { data = d; next = link; } public Element add(Object d) { return new Element (d, this); } public void append (Object d) { Element t = this; while (t.next != null) t = t.next; t.next = new Element(d,null); } public void print () { Element t = this; while (t != null) { System.out.print (t.data + " "); t = t.next; } } } class List1 { public static void main (String[] args) { Element top = new Element(" Hello ", new Element(" world. ", null)); top = top.add(" world. "); top = top.add(" Bye bye "); top.print(); } }