public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
class Inner//内部类
{
private int x=1;
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public void function()
{
//int x = 6;
System.out.println("innner :"+this.x);
}
}
/**/
public Inner method()//此方法应该返回一个内部类对象
{
//Inner in = new Inner();//这种写法只能在本类中使用,在其他类中无法访问,因为不知道这个内部类在哪个外部类中。所以无法访问
Outer1.Inner in = new Outer1().new Inner();//这种写法是在其他类中调用Outer1中Inner类的对象
return in;
//in.function();
}
}作者: 唐晓 时间: 2013-1-29 08:12