Java oop的題與代碼4:統(tǒng)計(jì)網(wǎng)站訪問量的例子

package b;
public class yonghu {
public static void main(String[] args) {
yonghu y = new yonghu("張三");
yonghu y1 = new yonghu("李四");
yonghu y2 = new yonghu("王五");
System.out.println("當(dāng)前網(wǎng)站訪問量為" + yonghu.fangwenliang);
}
private String name;
static int fangwenliang;
yonghu(String name) {
fangwenliang++;
this.name = name;
System.out.println(this.name + "進(jìn)入了我的網(wǎng)站");
}
}

標(biāo)簽: