Java - final variables

前端 未结 7 1292
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-16 01:43

I know that once a final variable has a value assigned to it, it cannot be changed. However I just have a couple of questions regarding this:

  • When I have a

7条回答
  •  孤街浪徒
    2020-12-16 02:16

    Final variables in class scope must be initialized within the declaration or in the constructor. You cannot assign to a final variable in the main function unless it was declared in the main function. All final fields must be initialized. All variables must be initialized before they are used.

提交回复
热议问题