Properties file vs Constants class in Java

前端 未结 8 1227
臣服心动
臣服心动 2020-12-16 11:03

I am a bit confused between using a constants file and properties file in Java.

How to decide when to use Constants.java and when to use a .properties

8条回答
  •  [愿得一人]
    2020-12-16 11:22

    • Constants - when you don't mind re-compiling the application each time you change value. Sort of an irony here. Why would you change something if it has been called a constant :)

    • Properties file - when you want the luxury of just changing the value and maybe restarting the application to pick up the change.

提交回复
热议问题