*
The moose likes Java in General and the fly likes 101 Q, verification on simple issue: objects in package Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "101 Q, verification on simple issue: objects in package" Watch "101 Q, verification on simple issue: objects in package" New topic
Author

101 Q, verification on simple issue: objects in package

Edmund Castermund
Ranch Hand

Joined: May 09, 2007
Posts: 82

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: 19653
    
  18

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 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Edmund Castermund
Ranch Hand

Joined: May 09, 2007
Posts: 82
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: 101 Q, verification on simple issue: objects in package
 
Similar Threads
using `instanceof`with an "object" parameter
Accessing a class in another Package
Creating a class with name "Object"
Netbeans and java source files
Signed jar becomes unsigned if loaded by URLClassLoader