no need to construct a new HelloWorld object:
System.out.println("访问外部类中的score:" + HelloWorld.score);
System.out.println("访问内部类中的score:" + score);
System.out.println("访问外部类中的score:" + HelloWorld.score);
System.out.println("访问内部类中的score:" + score);
2015-10-01
System.out.println("外部类中的name:" +HelloWorld.this.name);
2015-10-01
static
{ System.out.println("通过静态初始化块初始化age");
age = 20;
}
public void show() {
System.out.println("姓名:" + name + ",性别:" + sex + ",年龄:" + age);
}
public static void main(String[] args) {
// 创建对象
HelloWorld hello = new HelloWorld();
hello.show();
{ System.out.println("通过静态初始化块初始化age");
age = 20;
}
public void show() {
System.out.println("姓名:" + name + ",性别:" + sex + ",年龄:" + age);
}
public static void main(String[] args) {
// 创建对象
HelloWorld hello = new HelloWorld();
hello.show();
2015-09-29