Possible Duplicate:
Is there a simple way of obtaining all object instances of a specific class in Java
In java, is there any possible way to get all the instances of a certain class?
Possible Duplicate:
Is there a simple way of obtaining all object instances of a specific class in Java
In java, is there any possible way to get all the instances of a certain class?
Not in general. If you're using the debugger API it may be possible (I haven't checked) but you shouldn't use that other than for debugging.
If your design requires this, it's probably worth rethinking that design.
You can use a Factory static initializer when you instantiate your class (Singleton pattern) and then add each generated instance in the factory constructor to a List ...
Something like this :