This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

101 Q, verification on simple issue: objects in package

 
Edmund Castermund
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Pie
Posts: 20669
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Edmund Castermund
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic