in pages 264 and 265 of the OCP Java book, there is an error. In table 5.7 default locale and default language should come after the root resource bundle java class or file.
Asking for a resource bundle for French in France with default locale US English, will make java look for french resources first till the top of the hierarchy of resources (the base resource) and then switch to the default locale or language.
It should look like this:
11. If still not found, throw MissingResourceException
Number 5 and 6 are the base for all resources, so Java will look for them before searching for the default locale or default language.
In your case, you don't have a French resource file, so there is no hierarchy established from French resource and the root resource file (Zoo.properties). Java went to the default resource file (Zoo_en_US.properties) immediately.
However, to understand my point, just add a blank French resource file (Zoo_fr_FR.properties) and run your code. You should get the value none for a.
Picking a resource is based on searching for a key. Suggesting to use a blank resource file was just to illustrate the point. However, if a locale resource file is present, but the key was not found inside it, where does Java go to search for the key?
Does it go to the root resource files or default resource files? It goes to the root resource files as shown by the example.
Therefore, I believe the correct order for table 5.7 is as outlined in my first post. The same thing applies to the list in page 265.
If a locale specific files are missing, then there is no need for any ordering as the search immediately goes to the default resource files and then the root resources.
I understand. I'm saying that the table is a simplifier version of the world where only property files with the property exist (or the file doesn't exist at all.) This is important for understanding the initial order.