Tuesday, April 24, 2012

How to count number of objects for a class in JVM

Simple ..


public class LikeThis {
  private static int numberOfObjectsCreated = 0;
 
   public  LikeThis() {
    numberOfObjectsCreated++;
    // other constructor business  
  }
}

No comments: