Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.Collections; import java.util.Currency; import java.util.HashMap; import java.util.Locale; import java.util.Map; public class Main { public static Map<String, String> countriesISOMap = new HashMap<String, String>(); public static ArrayList<String> getCountriesArray1() { Locale[] locales = Locale.getAvailableLocales(); ArrayList<String> countries = new ArrayList<String>(); for (Locale locale : locales) { String country = locale.getDisplayCountry(); Currency currency = Currency.getInstance(locale); if (country.trim().length() > 0 && !countries.contains(country) && !country.trim().equals("World")) { countries.add(country + " (" + currency + ")"); } } Collections.sort(countries); setCountriesISOMap(); return countries; } public static void setCountriesISOMap() { String[] isoCountryCodes = Locale.getISOCountries(); for (int i = 0; i < isoCountryCodes.length; i++) { Locale locale = new Locale("", isoCountryCodes[i]); countriesISOMap.put(locale.getDisplayCountry(), isoCountryCodes[i]); } } }