+ 1

How to access getradius method in this code

https://code.sololearn.com/ctiAfQXv6RJy/?ref=app

24th Aug 2021, 4:57 AM
Lathesh poojary
Lathesh poojary - avatar
2 Answers
+ 2
Your Geometry class does not have a getradius method, however its subclasses do have. Since you have an array of Geometry, you need to cast the element to its proper type before you can access this method. Circle c = (Circle) obj[0]; System.out.println(c.getradius());
24th Aug 2021, 5:06 AM
Tibor Santa
Tibor Santa - avatar
+ 1
Tq so much 🙏🙏
24th Aug 2021, 8:35 AM
Lathesh poojary
Lathesh poojary - avatar