Originally posted by Enge Chall:
Hi,
How to track the number of objects created, of a perticular class ?
I mean without using static variables.
Qn is is there any java API which can provide the number of objects created for a perticular class ?
thanks in advance.
Chall.
Everything is possible without static variables. In fact, the very notion of "class-scoped" data is an abstraction leak. The question you might want is "how do I provide global access to some shared piece of information, such as number of instances?" This would require you to pass a callback instance to all constructors. There are many related side issues to this common question, but I'll leave those for you to explore.