1

I'm testing java.util.Locale and I found that the first element of Locale.getAvailableLocales is weird.

@Test
public void printFirstLocale() {
    final Locale firstLocale = Locale.getAvailableLocales()[0];
    System.out.println("first locale: " + firstLocale
                       + " " + firstLocale.hashCode());
}

Ant it just prints this.

first locale:  0

I got same results from OS X, Windows, and Xubuntu.

Jin Kwon
  • 20,295
  • 14
  • 115
  • 184
  • 3
    I'm out of votes, but [java.util.Locale has an empty first item](http://stackoverflow.com/questions/14088874/java-util-locale-has-an-empty-first-item) – Sotirios Delimanolis Nov 16 '15 at 23:53
  • It's, shortly, [Locale.ROOT](http://docs.oracle.com/javase/7/docs/api/java/util/Locale.html#ROOT). – Jin Kwon Nov 17 '15 at 00:04

1 Answers1

1

First Locale is an empty String. It is covered here: http://docs.oracle.com/javase/7/docs/api/java/util/Locale.html

Returns the country/region code for this locale, which should either be the empty string, an uppercase ISO 3166 2-letter code, or a UN M.49 3-digit code.

m.aibin
  • 3,528
  • 4
  • 28
  • 47