To reference a specific object inside an Array, i need to cast int to it's type or the compiler do not accept, why do i need this casting?
Exemple:
Person[] people = Person[5]; //Generic Array of specific objects
Employee employee1 = new Employee(); //Employee class extends Person
Manager manager1 = new Manager(); //Manager class extends Person
people[0] = employee1;
people[1] = manager1;
Person ref = people[0]; //OK! it can compile
Employee ref2 = people[1]; //Do not compile
Employee ref2 = (Employee) people[1]; //OK! it can compile
Why do the cast is necessary?