Java Locale.getLanguage()

Syntax

Locale.getLanguage() has the following syntax.

public String getLanguage()

Example

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


//  www  .  j  a v  a2 s .co m
import java.util.Locale;

public class Main {

   public static void main(String[] args) {
      Locale locale = new Locale("en", "US", "WIN");

      System.out.println("Locale:" + locale);

      // get language and print it
      System.out.println("Language:" + locale.getLanguage());
   }
}

The code above generates the following result.