/* * decorator in linked list 's point of view ?????? */ class TestClass { String desc; TestClass tc; public TestClass(TestClass tc, String desc) { this.tc = tc; this.desc = tc == null ? "" : tc.desc + desc; } public String getDesc() { return desc; } } public class Hello { public static void main(String[] args) { TestClass t = new TestClass(new TestClass(new TestClass(new TestClass(null, ""), "A"), "B"), "C"); System.out.println(t.getDesc()); TestClass t2 = new TestClass(null, ""); char a = 'A'; while (a <= 'Z') { t2 = new TestClass(t2, new Character(a).toString()); a++; } System.out.println(t2.getDesc()); } }