public class StringNode { private char ch; private StringNode next; public StringNode(char c, StringNode n) { ch = c; next = n; } public static StringNode copy(StringNode str) { if (str == null) { return null; } StringNode copyRest = copy(str.next); return new StringNode(str.ch, copyRest); } public static void main(String[] args) { StringNode s1 = new StringNode('t', null); s1 = new StringNode('a', s1); s1 = new StringNode('c', s1); StringNode copied = StringNode.copy(first); } }