一、题目
二、源代码
import java.util.*; public class CountClass { private static int N=0; CountClass(){ N++; } public void print() { System.out.println("已经创建了"+N+"个对象"); } public static void main(String[] args) { int n,i; CountClass A=new CountClass(); CountClass B=new CountClass(); CountClass C=new CountClass(); CountClass D=new CountClass(); D.print(); A.print(); } }