Hi ,I have super class vehicle,truck extends vehicle,and I created array in test class full with objects from vehicle and truck,how can I call method from vehicle,is this the way
(truck)object1[1].getMethod()
kukuruku 0 Light Poster
Recommended Answers
Jump to Post— jwenting 1,905data[2].getLoadCap();should be
((Truck)data[2]).getLoadCap();as already explained.
And of course ideally you'd handle errors doing the casting.
All 3 Replies
Reply to this topic Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.