📄 statisticsdemo.java
字号:
// 例2.3.2 StatisticsDemo.java
class Counter
{
private static int number; // 声明一个静态私有变量
private int m; // 声明一个私有变量
public Counter() // 构造函数
{
m++; number++;
System.out.println("This is NO. "+number+" object,m = "+m);
}
}
public class StatisticsDemo
{
public static void main(String args[])
{
for(int i=0;i<Math.random()*10;i++)
new Counter();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -