SummingVisitorDJ { // how to use: // to sum all get_y() parts of type int belonging to class X // change "Weight" to "X", change "get_i()" to "get_y()" // Java does not support this parameterization {{ public void start() { total=0; System.out.println("begin"); } public void before(Weight o) { System.out.println("sum: add " + o.get_i() ); total += o.get_i(); } public Object getReturnValue() {return new Integer(total);} }} }