when exactly are we supposed to use “public static final String”?

前端 未结 11 1189
你的背包
你的背包 2020-12-07 12:08

I have seen much code where people write public static final String mystring = ... and then just use a value.

Why do they have to do that? Why do they h

11条回答
  •  抹茶落季
    2020-12-07 13:01

    final indicates that the value cannot be changed once set. static allows you to set the value, and that value will be the same for ALL instances of the class which utilize it. Also, you may access the value of a public static string w/o having an instance of a class.

提交回复
热议问题