newInstance()?
One of hundreds of answers available with our premium content service.
A: When you want to instantiate one of several possible sub-classes at runtime it is best to create an interface type that defines the common behaviour of those classes. For instance, you might define a Processor interface with one common method, as shown below.
… full answer hidden
Premium members click below for full answer
How can I cast an unknown sub-class returned by newInstance()?