Java Locale getISOLanguages() Method



Description

The Java Locale getISOLanguages() method returns a list of all 2-letter language codes defined in ISO 639. Can be used to create Locales.

Declaration

Following is the declaration for java.util.Locale.getISOLanguages() method

public static String[] getISOLanguages()

Parameters

NA

Return Value

This method returns the arrays of language codes.

Exception

NA

Getting Array of ISO Languages from Locale Example

The following example shows the usage of Java Locale getISOLanguages() method. We're printing a list of 2 letter language codes as defined in ISO 3166.

package com.tutorialspoint;

import java.util.Locale;

public class LocaleDemo {
   public static void main(String[] args) {

      // get ISO languages
      String[] languages = Locale.getISOLanguages();

      // print languages
      System.out.println("Languages are:");
      
      for (int i = 0; i < languages.length; i++) {
         System.out.println(i + ":" + languages[i]);
      }
   }
}

Output

Let us compile and run the above program, this will produce the following result −

Languages are:
0:aa
1:ab
2:ae
3:af
4:ak
...
187:zu
java_util_locale.htm
Advertisements