決賽與有效決賽的區別我正在使用Java 8中的lambdas,我遇到了警告local variables referenced from a lambda expression must be final or effectively final..我知道當我在匿名類中使用變量時,它們在外部類中必須是最終變量,但是-最終和有效終?
3 回答

瀟湘沐
TA貢獻1816條經驗 獲得超6個贊
其值在初始化后從未更改的變量或參數實際上是最終變量或參數。
public class Foo { public void baz(int bar) { // While the next line is commented, bar is effectively final // and while it is uncommented, the assignment means it is not // effectively final. // bar = 2; }}
添加回答
舉報
0/150
提交
取消