统计创建的对象个数

public class 统计 {

        public static int num=0;
        public 统计() {
            num++;
        }
        public static void main(String[] args) {
            统计 i=new 统计();
            统计 j=new 统计();
            System.out.println(num);
        }
    }

结果是2

posted @ 2018-10-21 18:00  birdmmxx  阅读(287)  评论(0)    收藏  举报