public class Shelter { Animal[] animals = new Animal[100]; // Another common, but hateful, naming style int animalCount=0; public void addAnimal(Animal animal) { animals[animalCount++]=animal; } public Animal getAnimal(int location) { return animals[location]; } public static void main(String[] args) { Shelter shelter = new Shelter(); // This is a common naming stule in java, It is OK for class but I hate it shelter.addAnimal(new Dog()); shelter.addAnimal(new Cat()); Cat c = (Cat)shelter.getAnimal(1); System.out.println(c); } }