What is the use of public final String[] getStringArray(String key)
in ResourceBundle?
Aren't keys
in properties files unique? Would this ever return more than one value? If not why does it return an array?
If you read carefully the documentation of ResourceBundle
, its says that: -
Resource bundles belong to families whose members share a common base name, but whose names also have additional components that identify their locales.
Also: -
Resource bundles contain key/value pairs. The keys uniquely identify a locale-specific object in the bundle.
So, keys are only unique for a particular locale. In two different locale, you can have keys that are same. That is why the return type is String[]
.
And for the method - getStringArray
: -
Gets a string array for the given key from this resource bundle or one of its parents.