Java Locale.getAvailableLocales()

Syntax

Locale.getAvailableLocales() has the following syntax.

public static Locale [] getAvailableLocales()

Example

In the following code shows how to use Locale.getAvailableLocales() method.


/*from  ww w .ja va2 s .  c  o m*/

import java.util.Locale;

public class Main {

   public static void main(String[] args) {
      // create a new array and get all installed locales
      Locale[] locales = Locale.getAvailableLocales();

      System.out.println("Installed locales are:");
      for (int i = 0; i < locales.length; i++) {
         System.out.println(i + ":" + locales[i]);
      }
   }
}

The code above generates the following result.