Java tutorial
import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class MainClass { public static void main(String[] args) { List cats = new ArrayList(); for (int i = 0; i < 7; i++) cats.add(new Cat(i)); Iterator e = cats.iterator(); while (e.hasNext()) ((Cat) e.next()).id(); } } class Cat { private int catNumber; public Cat(int i) { catNumber = i; } public void id() { System.out.println("Cat #" + catNumber); } } /* */