Java.util.Locale.getLanguage() Method
Advertisements
Description
The java.util.Locale.getLanguage() method returns the language code for this locale, which will either be the empty string or a lowercase ISO 639 code.
Declaration
Following is the declaration for java.util.Locale.getLanguage() method
public String getLanguage()
Parameters
NA
Return Value
This method does not return a value.
Exception
NA
Example
The following example shows the usage of java.util.Locale.getLanguage() method.
package com.tutorialspoint;
import java.util.*;
public class LocaleDemo {
public static void main(String[] args) {
// create a new locale
Locale locale = new Locale("en", "US", "WIN");
// print locale
System.out.println("Locale:" + locale);
// get language and print it
System.out.println("Language:" + locale.getLanguage());
}
}
Let us compile and run the above program, this will produce the following result:
Locale:en_US_WIN Language:en