标签:bubuko main 图片 info image ima stat shu ++
1 public class DuiXiang { 2 public static void main(String args[]) { 3 TongJi x=new TongJi(); 4 x.shuchu(); 5 TongJi y=new TongJi(); 6 y.shuchu(); 7 TongJi z=new TongJi(); 8 z.shuchu(); 9 } 10 11 } 12 class TongJi{ 13 static int sum=0; 14 TongJi(){ 15 sum++; 16 } 17 public void shuchu() { 18 System.out.println("你已创建"+sum+"个对象。"); 19 } 20 }
运行结果如下:
标签:bubuko main 图片 info image ima stat shu ++
原文地址:https://www.cnblogs.com/Qi77/p/9825655.html