Java Programing laungage

java.util Projects

java.util Project 1

Listing of all available Locales

It is the class of java.util.*; package, which is used to represents the geographical, political and cultural region. Every tasks which requires to perform the operation is called local-sensitive. In this world, each places have it's own country name, language name etc. these can be determined by the object of the Locale class.

Previous Home Next

Locale.getAvailableLocales(): This method is used to return an array of available locales, which are installed with your sdk.

Locale.getLanguage(): This method returns the language for the specified locale. We can show the full name of the language by using the getDisplayLanguage() method.

Locale.getCounty(): It is used to returns the two character country code for the specific locale. If you want to display the full name of the country then we can use the getDisplayCountry() method.

Locale.getDisplayName(): This method used to display the full description about the created locale that means the specific political or geographical or the cultural region.


package r4r;
import java.util.*;
public class listinglocaletest {
public static void main(String[] args)
Locale[] loc = Locale.getAvailableLocales(); for(int i = 0; i < loc.length; i++){ String language = loc[i].getLanguage(); String country = loc[i].getCountry(); String local_name = loc[i].getDisplayName(); System.out.println(i + ": " + language + ", " + country + "," + local_name); } } }
Previous Home Next