import java.util.Scanner;
public class Number {
private static int i = 0;
public Number()
{
i++;
}
public static int getNumber()
{
return i;
}
public static void main(String[] args) {
Number t1 = new Number();
Number t2 = new Number();
Number t3 = new Number();
Number t4 = new Number();
System.out.println("一共创建了" + Number.getNumber() + "个对象");
}
}
原文地址:https://www.cnblogs.com/fuheishi/p/9825992.html
时间: 2025-01-16 15:43:18