I have a question about the following example, inspired from OCP: Oracle Certified Professional Java SE 8 Programmer II Study Guide (page 265-266).
Suppose I have the following properties files:
Zoo_en_CA.properties visitor=Canada visitor
Zoo_fr_CA.properties visitor=Canada visiteur
name=Zoo de Vancouver
From what I understand (see table 5.7 on page 264), Java looks first into Zoo_en_CA.properties (requested locale) and doesn't find the key. Then it looks into Zoo_en.properties (requested language with no country) and doesn't find the key. Finally, it looks into Zoo_fr_CA.properties (default locale) and finds the key.
So why do I get a java.util.MissingResourceException when running this code? Can anyone tell me where I'm wrong?
Guillaume Bailly wrote:So it will not combine the different properties files to find all the keys if they are spread.
This is kind of an English thing, but not quite.
Suppose the first property is found in Zoo_en_CA.properties. It will look at Zoo_en.properties for future matches. It won't look in Zoo_fr.properties because it got excited about finding a match and knows where to look for more 0 in the match and it's parent(s).