Alan Shiers wrote:Class<SearchWorkerThread> theClass = Class.forName("CustomWorkerThread");
Paul Clapham wrote:
Alan Shiers wrote:Class<SearchWorkerThread> theClass = Class.forName("CustomWorkerThread");
I guess you're on the right track, but if your subclasses are already all known at compile time, then that's the hard way to do it. Just use the "class" literal of the class:
and make the compiler catch your spelling errors. Using Class.forName leaves the spelling errors to cause exceptions at run-time.
Jeff Verdegan wrote:Or am I missing something in the OP's requirements?
Paul Clapham wrote:
Jeff Verdegan wrote:Or am I missing something in the OP's requirements?
What I've seen of the requirements don't tell me whether your suggestion would be possible or not. It's certainly preferable to use ordinary constructors rather than Class.newInstance() where possible, but whether that works for Alan, I can't tell.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |