方法局部内部类不能使用方法内声明的变量 [英] method-local inner class cannot use variables declared within the method
本文介绍了方法局部内部类不能使用方法内声明的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么局部于方法内部的类不能使用在封闭方法内部声明的变量,除了标记为final的那些变量外,我知道在内部类实例保持有效的同时,在封闭方法内部声明的变量可能会消失,但是当这个变量声明为最终变量?
Why a method-local inner class can't use variables declared inside the enclosing method except those marked final, i know that the variables declared inside the enclosing method might vanishes while the inner class instance remains valid, but what has changed when this variable/s is declared final?
推荐答案
查看全文