public class Outer { private int a=99; public class Inner { int b=4; public void test() { System.out.println("访问外部类"+a); System.out.println("访问内部类"+b); } } public static void main(String[] args) { Outer o=new Outer(); Inner i=o.new Inner(); i.test(); }