0

For example, if I have a Stage with Buttons and Panes, should they be declared as static final by default?

1
  • Unless you have specific need, variables should never be static. Constants should be static and final. Commented Nov 26, 2020 at 6:15

1 Answer 1

2

Static variables mean they are in the application scope. So, all objects of the containing class will have the same value . In other words, static variables belong to class level instead of object level. So, if there are some variables which fulfill this criteria while you are coding, make them static.

Final variables are the ones whose value will not change once initialized. So, if there is any variable whose value is not going to change through the application then make it as final.

Example, constants in a Java file are defined as static final. There can be other cases too.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.