Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

import java.util.Collections;
import java.util.Currency;

import java.util.Locale;

public class Main {
    public static ArrayList<String> getCountriesArray() {
        String[] locales = Locale.getISOCountries();
        ArrayList<String> countries = new ArrayList<String>();
        for (String countryCode : locales) {

            Locale locale = new Locale("", countryCode);
            try {
                Currency currency = Currency.getInstance(locale);
                countries.add(locale.getDisplayCountry() + " (" + currency.getCurrencyCode() + ")");
            } catch (Exception e) {

            }
        }
        Collections.sort(countries);
        return countries;
    }
}