Difference between final and effectively final

后端 未结 14 2808
孤独总比滥情好
孤独总比滥情好 2020-11-22 00:38

I\'m playing with lambdas in Java 8 and I came across warning local variables referenced from a lambda expression must be final or effectively final. I know tha

14条回答
  •  迷失自我
    2020-11-22 01:11

    'Effectively final' is a variable which would not give compiler error if it were to be appended by 'final'

    From a article by 'Brian Goetz',

    Informally, a local variable is effectively final if its initial value is never changed -- in other words, declaring it final would not cause a compilation failure.

    lambda-state-final- Brian Goetz

提交回复
热议问题