Declare final variable, but set later

后端 未结 7 1574
梦毁少年i
梦毁少年i 2020-12-09 01:49

I know this is fairly simple topic, but I really want to wrap my head around it.

This is what I\'m trying to do, but it doesn\'t like the final modifier. Is there an

7条回答
  •  难免孤独
    2020-12-09 02:10

    You can set a final variable only in a constructor or in an initializer. Regular methods cannot change the value of variables declared final.

提交回复
热议问题