黑马程序员技术交流社区
标题:
。。。。。出道题做做。。。。。。。
[打印本页]
作者:
班志国
时间:
2012-11-3 17:33
标题:
。。。。。出道题做做。。。。。。。
class Outer{
int x = 6;
class Inner{
int x = 7;
void met(){
int x = 4;
System.out.println(Outer.this.x);
System.out.println(this.x);
System.out.println(x);
}
}
public static void main(String[] args){
Outer.Inner in = new Outer().new Inner();
in.met();
}
}
打印结果是多少
复制代码
作者:
王亚运
时间:
2012-11-3 17:48
6 //内部类对象调用外部类变量
7//内部类对象调用内部类变量
4//内部类对象调用方法局部变量
刚才还试了试 改成
static int x = 6;
然后,this 就可以省略了。。
话说对内部类很头疼,领教了。
{:soso__6468533990763016983_4:}
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2