Make use of the below code if you want to work with the list of Countries in the World and their 2-character ISO country codes.
/**
* Method to get a sorted map of country names and their
* ISO 3166 Country Codes
*
* @return Treemap of <Country,Country Code>
*/
public Map<String,String> getCountryCodeDetails() {
Map<String, String> mapOfCountryAndCodes = new TreeMap();
String[] countriesLocaleArr = Locale.getISOCountries();
for (String countryCode : countriesLocaleArr) {
Locale locale = new Locale("en", countryCode);
mapOfCountryAndCodes.put(locale.getCountry(), locale.getDisplayCountry());
}
return mapOfCountryAndCodes;
}
Example:
Map<String,String> countryCodeMap = countryCodes.getCountryCodeDetails();
countryCodeMap.forEach((code, country) -> System.out.println((code + ": " + country)));
Output List:
A
Country Code | Country Name |
---|---|
AD | Andorra |
AE | United Arab Emirates |
AF | Afghanistan |
AG | Antigua & Barbuda |
AI | Anguilla |
AL | Albania |
AM | Armenia |
AN | Netherlands Antilles |
AO | Angola |
AQ | Antarctica |
AR | Argentina |
AS | American Samoa |
B
Country Code | Country Name |
---|---|
AT | Austria |
AU | Australia |
AW | Aruba |
AX | Åland Islands |
AZ | Azerbaijan |
BA | Bosnia & Herzegovina |
BB | Barbados |
BD | Bangladesh |
BE | Belgium |
BF | Burkina Faso |
BG | Bulgaria |
BH | Bahrain |
BI | Burundi |
BJ | Benin |
BL | St. Barthélemy |
BM | Bermuda |
BN | Brunei |
BO | Bolivia |
BQ | Caribbean Netherlands |
BR | Brazil |
BS | Bahamas |
BT | Bhutan |
BV | Bouvet Island |
BW | Botswana |
BY | Belarus |
BZ | Belize |
C
Country Code | Country Name |
---|---|
CA | Canada |
CC | Cocos (Keeling) Islands |
CD | Congo - Kinshasa |
CF | Central African Republic |
CG | Congo - Brazzaville |
CH | Switzerland |
CI | Côte d’Ivoire |
CK | Cook Islands |
CL | Chile |
CM | Cameroon |
CN | China |
CO | Colombia |
CR | Costa Rica |
CU | Cuba |
CV | Cape Verde |
CW | Curaçao |
CX | Christmas Island |
CY | Cyprus |
CZ | Czechia |
D
Country Code | Country Name |
---|---|
DE | Germany |
DJ | Djibouti |
DK | Denmark |
DM | Dominica |
DO | Dominican Republic |
DZ | Algeria |
E
Country Code | Country Name |
---|---|
EC | Ecuador |
EE | Estonia |
EG | Egypt |
EH | Western Sahara |
ER | Eritrea |
ES | Spain |
ET | Ethiopia |
F
Country Code | Country Name |
---|---|
FI | Finland |
FJ | Fiji |
FK | Falkland Islands |
FM | Micronesia |
FO | Faroe Islands |
FR | France |
G
Country Code | Country Name |
---|---|
GA | Gabon |
GB | United Kingdom |
GD | Grenada |
GE | Georgia |
GF | French Guiana |
GG | Guernsey |
GH | Ghana |
GI | Gibraltar |
GL | Greenland |
GM | Gambia |
GN | Guinea |
GP | Guadeloupe |
GQ | Equatorial Guinea |
GR | Greece |
GS | South Georgia & South Sandwich Islands |
GT | Guatemala |
GU | Guam |
GW | Guinea-Bissau |
GY | Guyana |
H
Country Code | Country Name |
---|---|
HK | Hong Kong SAR China |
HM | Heard & McDonald Islands |
HN | Honduras |
HR | Croatia |
HT | Haiti |
HU | Hungary |
I
Country Code | Country Name |
---|---|
ID | Indonesia |
IE | Ireland |
IL | Israel |
IM | Isle of Man |
IN | India |
IO | British Indian Ocean Territory |
IQ | Iraq |
IR | Iran |
IS | Iceland |
IT | Italy |
J
Country Code | Country Name |
---|---|
JE | Jersey |
JM | Jamaica |
JO | Jordan |
JP | Japan |
K
Country Code | Country Name |
---|---|
KE | Kenya |
KG | Kyrgyzstan |
KH | Cambodia |
KI | Kiribati |
KM | Comoros |
KN | St. Kitts & Nevis |
KP | North Korea |
KR | South Korea |
KW | Kuwait |
KY | Cayman Islands |
KZ | Kazakhstan |
L
Country Code | Country Name |
---|---|
LA | Laos |
LB | Lebanon |
LC | St. Lucia |
LI | Liechtenstein |
LK | Sri Lanka |
LR | Liberia |
LS | Lesotho |
LT | Lithuania |
LU | Luxembourg |
LV | Latvia |
LY | Libya |
M
Country Code | Country Name |
---|---|
MA | Morocco |
MC | Monaco |
MD | Moldova |
ME | Montenegro |
MF | St. Martin |
MG | Madagascar |
MH | Marshall Islands |
MK | North Macedonia |
ML | Mali |
MM | Myanmar (Burma) |
MN | Mongolia |
MO | Macao SAR China |
MP | Northern Mariana Islands |
MQ | Martinique |
MR | Mauritania |
MS | Montserrat |
MT | Malta |
MU | Mauritius |
MV | Maldives |
MW | Malawi |
MX | Mexico |
MY | Malaysia |
MZ | Mozambique |
N
Country Code | Country Name |
---|---|
NA | Namibia |
NC | New Caledonia |
NE | Niger |
NF | Norfolk Island |
NG | Nigeria |
NI | Nicaragua |
NL | Netherlands |
NO | Norway |
NP | Nepal |
NR | Nauru |
NU | Niue |
NZ | New Zealand |
O
Country Code | Country Name |
---|---|
OM | Oman |
P
Country Code | Country Name |
---|---|
PA | Panama |
PE | Peru |
PF | French Polynesia |
PG | Papua New Guinea |
PH | Philippines |
PK | Pakistan |
PL | Poland |
PM | St. Pierre & Miquelon |
PN | Pitcairn Islands |
PR | Puerto Rico |
PS | Palestinian Territories |
PT | Portugal |
PW | Palau |
PY | Paraguay |
Q
Country Code | Country Name |
---|---|
QA | Qatar |
R
Country Code | Country Name |
---|---|
RE | Réunion |
RO | Romania |
RS | Serbia |
RU | Russia |
RW | Rwanda |
S
Country Code | Country Name |
---|---|
SA | Saudi Arabia |
SB | Solomon Islands |
SC | Seychelles |
SD | Sudan |
SE | Sweden |
SG | Singapore |
SH | St. Helena |
SI | Slovenia |
SJ | Svalbard & Jan Mayen |
SK | Slovakia |
SL | Sierra Leone |
SM | San Marino |
SN | Senegal |
SO | Somalia |
SR | Suriname |
SS | South Sudan |
ST | São Tomé & Príncipe |
SV | El Salvador |
SX | Sint Maarten |
SY | Syria |
SZ | Eswatini |
T
Country Code | Country Name |
---|---|
TC | Turks & Caicos Islands |
TD | Chad |
TF | French Southern Territories |
TG | Togo |
TH | Thailand |
TJ | Tajikistan |
TK | Tokelau |
TL | Timor-Leste |
TM | Turkmenistan |
TN | Tunisia |
TO | Tonga |
TR | Turkey |
TT | Trinidad & Tobago |
TV | Tuvalu |
TW | Taiwan |
TZ | Tanzania |
U
Country Code | Country Name |
---|---|
UA | Ukraine |
UG | Uganda |
UM | U.S. Outlying Islands |
US | United States |
UY | Uruguay |
UZ | Uzbekistan |
V
Country Code | Country Name |
---|---|
VA | Vatican City |
VC | St. Vincent & Grenadines |
VE | Venezuela |
VG | British Virgin Islands |
VI | U.S. Virgin Islands |
VN | Vietnam |
VU | Vanuatu |
W
Country Code | Country Name |
---|---|
WF | Wallis & Futuna |
WS | Samoa |
YE | Yemen |
YT | Mayotte |
Z
Country Code | Country Name |
---|---|
ZA | South Africa |
ZM | Zambia |
ZW | Zimbabwe |
Facing issues? Have Questions? Post them here! I am happy to answer!
Author Info:
Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.
Follow him on: X
You can also reach out to him via e-mail: rakesh@code2care.org
More Posts related to Java,
- Get the current timestamp in Java
- Java Stream with Multiple Filters Example
- Java SE JDBC with Prepared Statement Parameterized Select Example
- Fix: UnsupportedClassVersionError: Unsupported major.minor version 63.0
- [Fix] Java Exception with Lambda - Cannot invoke because object is null
- 7 deadly java.lang.OutOfMemoryError in Java Programming
- How to Calculate the SHA Hash Value of a File in Java
- Java JDBC Connection with Database using SSL (https) URL
- How to Add/Subtract Days to the Current Date in Java
- Create Nested Directories using Java Code
- Spring Boot: JDBCTemplate BatchUpdate Update Query Example
- What is CA FE BA BE 00 00 00 3D in Java Class Bytecode
- Save Java Object as JSON file using Jackson Library
- Adding Custom ASCII Text Banner in Spring Boot Application
- [Fix] Java: Type argument cannot be of primitive type generics
- List of New Features in Java 11 (JEPs)
- Java: How to Add two Maps with example
- Java JDBC Transition Management using PreparedStatement Examples
- Understanding and Handling NullPointerException in Java: Tips and Tricks for Effective Debugging
- Steps of working with Stored Procedures using JDBCTemplate Spring Boot
- Java 8 java.util.Function and BiFunction Examples
- The Motivation Behind Generics in Java Programming
- Get Current Local Date and Time using Java 8 DateTime API
- Java: Convert Char to ASCII
- Deep Dive: Why avoid java.util.Date and Calendar Classes
More Posts:
- VS Code: The source path must be contained in the project root folder. - Java
- Java 8 Display time in 12 hour AM PM format - Java
- [Solved] SharePoint Access Denied error editing Document Name - SharePoint
- Open Docker from Terminal Command on Mac - MacOS
- Add Current Date and Time in Notepad++ - NotepadPlusPlus
- How to Download and Install Roblox Studio on Mac (M1/M2/Intel) - MacOS
- How to Peek into tabs in Notepad++ using Document Peeker - NotepadPlusPlus
- How to find version of Cargo in Rust - Rust