Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Locale;
- public class Countries {
- public static void main(String[] args) {
- // Using Locale class static method getISOCountries()
- // we extract a list of all 2-letter country codes
- // defined in ISO 3166. Can be used to create Locales.
- String[] countries = Locale.getISOCountries();
- String[] country = new String[countries.length];
- // Loop each country
- for(int i = 0; i < countries.length; i++) {
- String c = countries[i];
- Locale locale = new Locale("en", c);
- // Get the country name by calling getDisplayCountry()
- String countryName = locale.getDisplayCountry();
- country[i] = countryName;
- System.out.println(country[i]);
- // Printing the country name on the console
- //System.out.println(i+1 + " : " + countryName);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment