为了账号安全,请及时绑定邮箱和手机立即绑定

方法中的内部类。如果方法中与内部类有相同的变量要怎么分别输出

public class Outer{
    public void show(){
        int b = 32;
        class Inner{
            int b =13;
            System.out.print("方法中的b:"+    ) ;//怎么写
        }
    }
}


正在回答

1 回答

public class Outer{

    public void show(){

        int b = 32;

        class Inner{

            int b =13;

            System.out.print("方法中内部的b:"+b +

                                      "\n方法中外部的b:"+Outer.this.b   ) ;//怎么写

        }

    }

}


0 回复 有任何疑惑可以回复我~
#1

慕盖茨7794722 提问者

好像不行呀
2017-06-02 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

方法中的内部类。如果方法中与内部类有相同的变量要怎么分别输出

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号