The Java Locale getISOCountries() method returns a list of all 2-letter country codes defined in ISO 3166. This can be used to create Locales.
DeclarationFollowing is the declaration for java.util.Locale.getISOCountries() method
public static String[] getISOCountries()Parameters
NA
Return ValueThis method returns the arrays of country codes.
ExceptionNA
Getting Array of ISO Countries from Locale ExampleThe following example shows the usage of Java Locale getISOCountries() method. We're printing a list of 2 letter country codes as defined in ISO 3166.
package com.tutorialspoint; import java.util.Locale; public class LocaleDemo { public static void main(String[] args) { // get ISO countries String[] countries = Locale.getISOCountries(); // print countries System.out.println("Countries are:"); for (int i = 0; i < countries.length; i++) { System.out.println(i + ":" + countries[i]); } } }Output
Let us compile and run the above program, this will produce the following result −
Countries are: 0:AD 1:AE 2:AF 3:AG 4:AI ... 248:ZW
java_util_locale.htm
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4