Java: how do I create a class that can keep track of how many times it has been instanciated?
Posted on 2005-04-02
First off, I am new to java and familiar with C++.. What I would like to do is create a class that instantiates each object with a unique positive ID. This is a "toy" problem. That is, I do not need any fancy identifiers - a simple integer that increments for each object created will do.. The trick is, how do I make the class remember how many objects have been initiallized so that I can simply assign the next free integer ID to a new object?
Thank you expterts!