Properties file vs Constants class in Java

前端 未结 8 1228
臣服心动
臣服心动 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:43

    You usually use property files when you want to specify parameters that vary from deployment to deployment or over time.

    You use constants when the parameters are not dynamic and thus not supposed to be changed depending on external factors. You have to recompile the class every time you change a value.

提交回复
热议问题