From the course: Java SE 21 Developer (1Z0-830) Cert Prep

Unlock this course with a free trial

Join today to access over 25,600 courses taught by industry experts.

Question deep dive

Question deep dive

- Let's look at a question on the locale and resources topic. So assuming the default locale is _fr_CA and given this directory tree that we see down here with partial file contents, what is the result of this piece of code? Well, the temptation is to look at this and say oh, there's messages and here are our messages, we have an _en_CA, well CA and CA, they're both Canada, but remember that French language is more important than English the language and therefore, that one will definitely not match _fr_CA. There is no _fr_CA in our properties, so the next thing that will be tried is simply fr. Well there's an fr, that makes it tempting to think that when we look up messages.name, we might find Jacques. But wait a minute, the key here is name. And this is asking for messages.name. We do not prefix our resource with the resource bundle name. That suggests that if we got to this point, we would potentially expect an…

Contents