package com_black.InnerClass.s1; public class Outer { private int s=10; /*public class Inner{ public void show(){ System.out.println(s); */ private class Inner{ public void show(){ System.out.println(s); } } public void method(){ Inner i=new Inner(); i.show(); } } package com_black.InnerClass.s1; public class InnerDemo { public static void main(String[] args) { //创建内部类对象并调用方法 //Inner i=new Inner(); 报错 /*Outer.Inner i=new Outer().new Inner(); i.show(); 对应public的Inner形式 */ Outer o=new Outer(); o.method(); } }
标签:Outer,内部,show,成员,void,Inner,new,public From: https://www.cnblogs.com/hxh-/p/17766464.html