Count the number of objects created for a class using static member function.

class CountObj {
    static int count = 0;
    CountObj() { 
        count++; 
    }
    static void show() { 
        System.out.println("Objects: " + count); 
    }
}
class CountStatic {
    public static void main(String[] args) {
        new CountObj(); 
        new CountObj();
        CountObj.show();
    }
}