Пример #1
0
  public static void main(String[] args) {
    Sequence s = new Sequence(2);
    System.out.println(s.add(new Cat()));
    System.out.println(s.add(new Mouse()));
    System.out.println(s.add(new Cat()));

    Iterator it = s.iterator();
    while (it.hasNext()) {
      Rodent o = (Rodent) s.next();
      o.eat();
    }
  }