Consider the following program and predict the output:
import java.util.Locale; class Main { public static void main(String []args) { Locale locale = new Locale("navi", "pandora"); //#1 System.out.println(locale); } }
NoSuchLocaleException
.e)
To create a Locale object using the constructor Locale (String language, String country), any String values can be passed; just attempting to create a Locale object will not result in throwing exceptions (other than a NullPointerException, which could be raised for passing null Strings).
The toString()
method of Locale class returns a string representation of the Locale object consisting of language, country, variant, etc.