Java is something what really impressed me than other programming languages anyways today we'll see how to list down all the countries and their country code . I don't know whether you know theres a small library called Locale in java.util namspace so that's what i am using here to do the thing .
import java.util.*;
/* Author : Mohamed Shimran
Blog : http://ultimateprogrammingtutorials.blogspot.com
*/
class Countries {
public static void main(String args[]) {
String[] cntry = Locale.getISOCountries();
for (String countryCode : cntry) {
Locale obj = new Locale("", countryCode);
System.out.println("Country Code = " + obj.getCountry()
+ ", Country Name = " + obj.getDisplayCountry());
}
}
}
NOTE: i was using public class but i had to remove it because my class thingy goes mad still it works actually public class is not needed.