源代码:
public class test { public static void main(String[] args) { test t1=new test(); test t2=new test(); test t3=new test(); test t4=new test(); System.out.println("一个创建了"+n+"个对象"); } static int n=0; public test() { n++; } }
测试截图