172.16.0.151_20200902-陈政平
问题
public class Human {
static String home = "地球" ;
String name = "人" ;
public static class Brain { // nested class (嵌套类)
String name = "脑子" ;
public void show() {
System.out.println("Human home : " + Human.home );
System.out.println("Brain name : " + this.name );
}
}
public class Heart { // non-static member class (实例内部类)
String name = "心脏" ;
public void show() {
System.out.println("Human home : " + Human.home );
System.out.println("Human name : " + Human.this.name );
System.out.println("Brain name : " + this.name );
}
}
1.System.out.println("Human home : " + Human.home ); 调用宿主类的变量要用宿主类的 类名.字段名 来调用
2.ZoneId zoneId = ZoneId.of( "Europe/London" );
System.out.println( zoneId );
TimeZone zone = TimeZone.getTimeZone( "Asia/Shanghai" );
System.out.println( zone );
这两者的区别是什么?
吐槽
点赞