java.util.Locale has an empty first item

后端 未结 3 754
悲哀的现实
悲哀的现实 2020-12-19 18:11

I am trying to get all the locales from the JVM to populate a Country drop down. The first item is an empty not null object. It isn\'t null because I am using a TreeMap Coll

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-19 18:31

    try

        for (Locale locale : Locale.getAvailableLocales()) {
            System.out.println(locale.getLanguage() + " " + locale.getCountry());
        }
    

    you will see that some Locales have only language and no country

    ms MY
    ar QA
    is IS
    fi FI
    pl 
    en MT
    ...
    

提交回复
热议问题