Scope of final local variable in java

前端 未结 2 1191
我在风中等你
我在风中等你 2021-01-18 17:07

Method-Local inner class cannot access local variables because the instance of the method-local inner class may still alive after the method is over. But local variables wil

2条回答
  •  北荒
    北荒 (楼主)
    2021-01-18 17:45

    No it doesn't. It means that a copy of the local variable is still alive, in the inner class instance. The 'final' just makes sure the two copies don't confusingly diverge in value.

提交回复
热议问题