- public class Outer {
- private static String str="外部类的私有成员变量";
- private static String show(){
- return"外部私有的成员方法";
-
- }
- class Inner{
- public void innerShow(){
- System.out.println("内部类调用了内部类的show函数");
- System.out.println("内部类访问了"+Outer.str);
- System.out.println("内部类调用了"+Outer.show());
- }
- }
- public static void main(String[] args) {
- Outer outer=new Outer();
- Inner inner= outer.new Inner();
- inner.innerShow();
-
- }
- }
复制代码 |