/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
List
Cow curCow = new Cow();
curCow.setAge(5);
cows.add(curCow);
System.out.println(cows.size());
for (int i = 1; i <= 20; i++) {
for (int j = 0; j < cows.size(); j++) {
curCow = cows.get(j).getCow();
if(null!=curCow)
cows.add(curCow);
}
}
System.out.println(cows.size());
}
}
class Cow{
private int age = 1;
public Cow getCow(){
if(age<5){
this.age++;
return null;
}
this.age++;
return new Cow();
}
public void setAge(int age){
this.age = age;
}
}