谁能帮我解释一个java小程序,我有一小部分看不懂
classOuter{intouter_i=50;privatevoidtest(){Innerin=newInner(this);in.display();}/*cla...
class Outer
{
int outer_i = 50;
private void test()
{
Inner in = new Inner(this);
in.display();
}
/*class Inner
{
void display()
{
System.out.println("outer_i = " + outer_i);
}
}*/
public static void main(String [] args)
{
Outer outer = new Outer();
outer.test();
}
}
class Inner
{
Outer outer = new Outer();
public Inner(Outer outer)
{
this.outer = outer;
}
void display()
{
System.out.println("outer_i = " + outer.outer_i);
}
}
第六行和第26到30行,谢谢啊~~~~~ 展开
{
int outer_i = 50;
private void test()
{
Inner in = new Inner(this);
in.display();
}
/*class Inner
{
void display()
{
System.out.println("outer_i = " + outer_i);
}
}*/
public static void main(String [] args)
{
Outer outer = new Outer();
outer.test();
}
}
class Inner
{
Outer outer = new Outer();
public Inner(Outer outer)
{
this.outer = outer;
}
void display()
{
System.out.println("outer_i = " + outer.outer_i);
}
}
第六行和第26到30行,谢谢啊~~~~~ 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询