casting in arrays | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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 Answer
+ 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