Is it possible to write a method that will count the number of object created?
In the past, I have counted objects by declaring a integer count variable and incrementing each time that constructor is called. However, I now want to write a method that will count objects on its own. For instance:
public class MyClass { private int numMyClass; public int countMyClassObjs { //Code that counts instances of MyClass return numMyClass; } }