interface Visitor { public void visit(Employee employee); public void visit(Manager manager); } interface Visitable { public void accept(Visitor v); } class Employee implements Visitable { ... public void accept(Visitor v) { v.visit(this); } } class Manager extends Employee { ... public void accept(Visitor v) { v.visit(this); } } public class Test { public static void main(String[] args) { ... Visitor v = new SomeVisitor(); // creeaza un obiect-vizitator concret for (Employee e : employees) e.accept(v); } }