Main { public static void main(String args[]) throws Exception {{ A a = A.parse(System.in); System.out.println(); a.print(); System.out.println(" A printed"); System.out.println(); ClassGraph cg = new ClassGraph(true, false); TraversalGraph tg = new TraversalGraph("from A to B",cg); a.getB(tg); }} } A { {{ void getB(TraversalGraph tg){ tg.traverse(this, new Visitor(){ void before(B b) { b.print(); System.out.println(" B printed");} // void before(C c) { c.print(); System.out.println(" C printed");} }); } }} }