Provided the final variable is used only inside one static method, should I declare it as final static member in class, or final variable in the static method.
If it is declared inside method, will it be initialized each time the function is called. (function is invoked a lot of times)
EDIT: The Variable is a List
initialized using Arrays.asList(...)
function
If it is declared inside method, will it be initialized each time the function is called. (function is invoked a lot of times)
Yes. If you declare your variable inside the method, it will invoke Arrays.asList(...)
each time the method is invoked.
If your variable has a costly initialization and/or the method is invoked a lot of times you should declare it as a private static final
field.