Difference between a static and a final static variable in Java

后端 未结 6 2003
梦谈多话
梦谈多话 2020-12-22 18:09

Generally, final static members especially, variables (or static final of course, they can be used in either order without overlapping the meaning) are extensively used with

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-22 18:37

    Static members are those which can be accessed without creating an object. This means that those are class members and nothing to do with any instances. and hence can not be defined in the method.

    Final in other terms, is a constant (as in C). You can have final variable inside the method as well as at class level. If you put final as static it becomes "a class member which is constant".

提交回复
热议问题