About Question enthuware.ocpjp.v21.2.4019 :
Moderator: admin
-
- Posts: 17
- Joined: Mon Sep 16, 2024 1:49 am
- Contact:
About Question enthuware.ocpjp.v21.2.4019 :
msgs.properties is searched for only default Locale?
-
- Site Admin
- Posts: 10382
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v21.2.4019 :
No, there is a complete process/algorithm that is used to search properties files for a given key. You can read it in detail either from the javadocs or just go through section 24.3.2 and 24.3.3 of OCP Java 17/21 Fundamentals by Hanumant Deshmukh. Attached is the relevant section:
-
- Site Admin
- Posts: 10382
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v21.2.4019 :
And the next page...
-
- Posts: 17
- Joined: Mon Sep 16, 2024 1:49 am
- Contact:
-
- Site Admin
- Posts: 10382
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v21.2.4019 :
Did you read the explanation provided with the question thoroughly?
See the lines in bold:
See the lines in bold:
If the above is not clear, please read the relevant sections of the book posted above. If that is not clear, please go through the JavaDoc of getBundle: https://docs.oracle.com/en/java/javase/ ... assLoader)When you look for a resource bundle for Locale.of("fr"), the localization framework will look for msgs_fr.properties file. However, in the given situation, msgs_fr.properties is not present. Although msgs_fr_FR.properties is present, it will not be used because fr_FR is not a parent of fr. fr is a parent of fr_FR.
Since the localization framework is not able to create a resource bundle for msgs_fr, it will look for a resource bundle for the default locale, which is en_GB. To create a resource bundle for en_GB, it will look for msgs_en_GB.properties, msgs_en.properties, and msgs.properties, in that order. It will not find msgs_en_GB.properties, but the other two are present. Thus, the entry accountinfo={0}''s balance is {1} from msgs_en.properties will be used.
-
- Posts: 17
- Joined: Mon Sep 16, 2024 1:49 am
- Contact:
Re: About Question enthuware.ocpjp.v21.2.4019 :
Thank you! Now I get it.
Who is online
Users browsing this forum: Bing [Bot] and 85 guests