JAVA 内部类
public class A { int i; public A() { // TODO Auto-generated constructor stub } class B { int j; int add() { return i + j; } } }
public class Test { public Test() { // TODO Auto-generated constructor stub } public static void main(String[] args) { // TODO Auto-generated method stub A a = new A(); a.i = 3; A.B b = a.new B(); b.j = 4; System.out.println(b.add()); } }
运行结果
7