aspose file tools
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
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply 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: 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.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: 101 Q, verification on simple issue: objects in package
 
Similar Threads
Netbeans and java source files
Creating a class with name "Object"
Signed jar becomes unsigned if loaded by URLClassLoader
using `instanceof`with an "object" parameter
Accessing a class in another Package