casting in arrays | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

casting in arrays

If Person is super and Sudents extends Person code: Person personlist = new Person[1]; personlist[0] = new Student(); Is there a type casting?

16th Jan 2018, 1:35 AM
Noperson
Noperson - avatar
1 Réponse
+ 1
there is no casting, there is polymorphism and it will throw an exception because array of length 1 has only index 0, not index 1
16th Jan 2018, 4:12 PM
michal