oop - Counter of interface objects in Java -
oop - Counter of interface objects in Java -
in java, if want know how many object of type myclass, can define myclass in way
public class myclass { public static int count = 0; public myclass() { count++; } //other stuff //... } and then, calling
myclass.count
i can number of objects created.
i wondering if there's way same thing interface, e.g. if have interface called icountable, how can know how many objects icountable there in programme @ moment. thinking of doing mill pattern, in design way notice weaknesses, haven't come working solution yet, know way this?
you have @ thread:
how many instances class exists @ runtime in java
but recommend, not implement such mechanism. there practically no utilize case in release code. , debugging / profiling there several tools. if remember correctly, eclipse profiler keeps track of instances out of box, start , watch.
java oop interface
Comments
Post a Comment