// A basic test for GCed memory allocation class Test1 { public static void main(String[] args) { int total = 0; int iters = Integer.parseInt(args[0]); for (int n = iters; n > 0; n--) { IList lst = null; int k = Integer.parseInt(args[1]); int l = Integer.parseInt(args[2]); for (int i = 0; i < l; i++) lst = new IList(k, lst); total += lst.sum(); } System.out.println(args[0] + " x " + args[1] + " x " + args[2] + " = " + total); } } class IList { private IList cdr; private int car; IList(int pcar, IList pcdr) { cdr = pcdr; car = pcar; } int car() { return car; } IList cdr() { return cdr; } int sum() { return car + (cdr != null ? cdr.sum() : 0); } }