Java中的属性文件vs Constants类 [英] Properties file vs Constants class in Java
问题描述
我在Java中使用常量文件和属性文件时有点困惑。
I am a bit confused between using a constants file and properties file in Java.
如何决定何时使用 Constants.java 何时使用 .properties 文件?
How to decide when to use Constants.java and when to use a .properties file?
推荐答案
在
Use hardwired constants in your Java code when you don't want users / deployers / testers / tests changing them.
你想要的时候使用属性文件这是一种可能性。
重点是在应用程序的源代码中更改硬连接常量需要编辑源代码,重建和重新部署。相比之下,更改属性文件可能就像启动NotePad一样简单。
The point is that changing a hard-wired constant in your application's source code entails editing the source code, rebuilding and redeploying. By contrast, changing a properties file may be as simple as firing up NotePad.
这篇关于Java中的属性文件vs Constants类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!