You are adding a new Dog each time checkAnimals is invoked, hence that output. try removing animals.add(new Dog) from checkAnimals() and you will get you're desired output of 2 Dogs, 2 Cats and 1 Bird.
Joined: Aug 06, 2006
oops! sorry i didn't see the last dog.
Joined: Aug 03, 2002
Originally posted by Amitabha Batranab: whoops . Thanks.
Yes, such problems can lose you a lot of time that could be spent otherwise. Inheritance can sometimes be a real pain.