Java中的属性文件vs Constants类 [英] Properties file vs Constants class in Java

查看:282
本文介绍了Java中的属性文件vs Constants类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在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?

推荐答案

中使用Java代码中的硬连线常量您不希望用户/部署者/测试人员/测试人员更改它们。

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆