The final local variable cannot be assigned

前端 未结 6 1971
说谎
说谎 2020-11-29 23:48

I have an array of seats, and the array has two strings(selected and empty). On mouse click, I want to traverse the array and find the selected seat. When I press the button

6条回答
  •  眼角桃花
    2020-11-30 00:26

    A final variable cannot change it's value (it's similar to const from C/C++).

    You probably want to make it a field in a class (without the final keyword of course), not a local variable inside a function.

提交回复
热议问题