What is best practice declare java file having only constant

What is best practice declare java file having only constant

Answer : If you using Java 5+  then enums is best way to define constant otherwise you could either choose class or interfaces for constant both are good it depends on your choice. Below are some best practice points when defining constants:

  • Constant name should be in upper case
  • Two words should be separated by underscore
  • You can control its accessibility using public or protected modifier

Leave a Reply

Your email address will not be published. Required fields are marked *