NumberFormat getAvailableLocales() method in Java with Examples

The getAvailableLocales() method is a built-in method of the java.text.NumberFormat returns an array of locales for which localized NumberFormat instances are available. All the returned values thus represents the local supported by Java runtime.

Syntax:

public static Locale[] getAvailableLocales()

Parameters: The function does not accepts a single parameter.



Return Value: The function returns an array of locales for which localized NumberFormat instances are available

Below is the implementation of the above function:

Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

// Java program to implement
// the above function
  
import java.text.NumberFormat;
import java.util.Locale;
  
public class Main {
    public static void main(String[] args)
        throws Exception
    {
  
        // Get all the available country names
        Locale[] arr
            = NumberFormat
                  .getAvailableLocales();
  
        // Iterate and print
        for (Locale it : arr) {
            System.out.println(
                it.getDisplayCountry()
                + " ");
        }
    }
}

chevron_right


Output:

United Arab Emirates 
Jordan 
Syria 
Croatia 
Belgium 
Panama 
Venezuela 
Malta 
 
Taiwan 
 
 
 
 
Denmark 
Puerto Rico 
Vietnam 
United States 
Montenegro 
Sweden 
Singapore 
Bolivia 
Bahrain 
 
Saudi Arabia 
 
Yemen 
India 
 
Malta 
Finland 
 
 
Bosnia and Herzegovina 
 
 
Ukraine 
Switzerland 
 
 
Argentina 
Egypt 
Japan 
El Salvador 
Brazil 
 
Czech Republic 
 
Iceland 
Spain 
Poland 
 
Serbia and Montenegro 
 
Malaysia 
 
Spain 
Bulgaria 
Colombia 
 
 
 
Bosnia and Herzegovina 
Paraguay 
 
 
Ecuador 
United States 
Sudan 
 
Romania 
Philippines 
 
Tunisia 
Montenegro 
Guatemala 
Cyprus 
South Korea 
 
Mexico 
Russia 
Honduras 
Norway 
Hong Kong 
Hungary 
Thailand 
Iraq 
Chile 
Morocco 
 
Ireland 
 
Turkey 
Qatar 
Estonia 
 
Portugal 
Luxembourg 
Oman 
 
Albania 
Dominican Republic 
Cuba 
 
 
New Zealand 
Serbia 
Switzerland 
Uruguay 
 
Greece 
Israel 
South Africa 
Thailand 
 
France 
Austria 
 
Norway 
Australia 
 
Canada 
Latvia 
Netherlands 
Luxembourg 
Costa Rica 
Kuwait 
Libya 
 
Switzerland 
 
 
Germany 
Algeria 
Slovakia 
Italy 
Lithuania 
Ireland 
Singapore 
Canada 
 
Belgium 
 
 
China 
Japan 
Greece 
Serbia 
 
India 
Lebanon 
Nicaragua 
 
Belarus 
Macedonia 
Slovenia 
Peru 
Indonesia 
United Kingdom

Reference: https://docs.oracle.com/javase/10/docs/api/java/text/NumberFormat.html#getAvailableLocales()



My Personal Notes arrow_drop_up

The function of education is to teach one to think intensively and to think critically

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.