Email address:
Password:
SCJP/OCPJP 1.6 certification
Practice Exams and Training
SCJP Online Training » Discussions

The first argument you pass to the Locale(String) constructor, should be the 'language'.

But "gb" is not a language but a country. Should'nt we get a compilation error here?

The compiler doesn't have a way to know what value you are passing/assigning. It only knows the type of the object/value you pass.


In this particular case, the compiler knows you are passing a String type value, but it doesn't have a way to know what it actually contains.


The closest possible error handling would have been throwing an exception (something like IllegalArgumentException would have been a good choice) when you pass an unrecognized value. However, for some reason the people who designed it decided to be gentle on invalid names.

ExamLab © 2008 - 2024