源码


public class statics {
   public static int num;
   public statics()
   {
      num++;
   }
   public static void main(String[] args)
   {
      num=0;
      statics a=new statics();
      statics b=new statics();
      statics c=new statics();
      System.out.printf("你已经创建了%d个对象",num);
   }
}

运行结果

你已经创建了3个对象

posted on 2019-10-16 11:25  嘻嘻_嘻  阅读(122)  评论(0编辑  收藏  举报