| Author |
101 Q, verification on simple issue: objects in package
|
Edmund Castermund
Ranch Hand
Joined: May 09, 2007
Posts: 77
|
|
This is one of the super basic newb q's I shouldn't need to ask, but..
Just need to verify two things:
1) there's no way to create a method that will return any object from a package, as in:
and 2) it's bad design to create an abstract superclass with no methods or properties so that you can do the above?
I'm just not crazy about
what are the best ways to deal with that issue?
thanks!
ec
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
Why would you want to do something like this? You get just any object, but you can't do anything with it. The least you should do is use a common interface. You can then perhaps use the ServiceLoader mechanism to return a number of implementations.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Edmund Castermund
Ranch Hand
Joined: May 09, 2007
Posts: 77
|
|
|
the immediate task is to read an xml file and create objects...I suppose I can create an arraylist of the top level objects and test each interface, as you say.
|
 |
 |
|
|
subject: 101 Q, verification on simple issue: objects in package
|
|
|