gpt4 book ai didi

java - 资源包中的键是否唯一?

转载 作者:行者123 更新时间:2023-12-01 15:05:02 24 4
gpt4 key购买 nike

ResourceBundle中的public final String[] getStringArray(String key)有什么用? ?
属性文件中的key不是唯一的吗?这会返回多个值吗?如果不是,为什么它返回一个数组?

最佳答案

如果你仔细阅读ResourceBundle的文档,它说:-

Resource bundles belong to families whose members share a common base name, but whose names also have additional components that identify their locales.

另外:-

Resource bundles contain key/value pairs. The keys uniquely identify a locale-specific object in the bundle.

因此,键仅对于特定区域设置是唯一的。在两个不同的区域设置中,您可以拥有相同的 key 。这就是返回类型为 String[] 的原因。

对于方法 - getStringArray :-

Gets a string array for the given key from this resource bundle or one of its parents.

关于java - 资源包中的键是否唯一?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13083171/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com