package ke2; public class Genzong { private static int n = 0; public Genzong() { n++; } public static int GetNum() { return n; } public static void main(String[] args) { Genzong n1=new Genzong(); Genzong n2=new Genzong(); Genzong n3=new Genzong(); Genzong n4=new Genzong(); Genzong n5=new Genzong(); Genzong n6=new Genzong(); System.out.println("已生成对象个数:"+Genzong.GetNum()); } }
原文地址:https://www.cnblogs.com/zlc364624/p/9825172.html
时间: 2024-11-05 13:39:43