Sagar Dabas wrote:
....Just want to save the typing overhead if there are many subclasses...
....
Is there any function in the java API like
...
So that i don't have to check for the every subclass object using
Oops. I guess I didn't read your original post closely enough. Yes, you can do something like that using reflection. Here's my example with reflection instead. I've left out exception handling, just to keep it brief, and you may have to fiddle with the generics a bit, and you'll have to do some studying to learn the details, but this should get you started:
Or you can just get rid of the generics and deal with casting, if you're not familiar with that concept.