直接方式:
外部类名称 . 内部类名称 = new 外部类名称(). new 内部名称();
public class BodyMain {
public static void main(String[] args) {
Body body = new Body();
body.methodBody();
System.out.println("= = = = = = = = =");
Body.Heart heart = new Body().new Heart();
heart.Beat();
}
}
输出:
外部方法
Heart beat!
my name is null
= = = = = = = = =
Heart beat!
my name is null