日期:2014-05-19 浏览次数:20631 次
package com; public class ClassA { private int x; private int y; //ClassA的构造函数 属性设置器等 public ClassA(int x, int y) { this.x = x; this.y = y; } class ClassB { public int add() { return x + y; } } public ClassB getClassB() { return new ClassB(); } public static void main(String[] args) { ClassA a = new ClassA(3, 5); ClassA.ClassB b = a.getClassB(); System.out.println(b.add()); } }