I don't understand why. If you're returning a bunch of Data objects to the page, what does the underlying implementation matter?MUST BE CASTED
Originally posted by Ryan McGuire:
Since data is a Data or some subclass, you can be sure that load() returns a Data. So you can cast the return value of load() to a Data right in the same line.
That's the point I was trying to make (ineffectually) in my first response. Good explanation!There's no need to use target.getClass() to select what type of functionality to use. That's exactly what polymorphism is for.
Consider Paul's rocket mass heater. |