Java Locale getLanguage() Example

Locale class getLanguage() method example. This example shows you how to use getLanguage() method.


Syntax is : public String getLanguage()
Method returns the language code for this locale, which will either be the empty string or a lowercase ISO 639 code.

Here is the code.

/**
 * @(#) GetLanguageLocale.java
 * A class representing use of method getLanguage() of Locale class
 in java.util Package.
 * @Version  24-May-2008
 @author   Rose India Team
 */
import java.util.*;

class GetLanguageLocale {
    public static void mainString args[] ){

    /* Create object of Locale class using contructor 
         Locale(String language, String country) */
         Locale obj1 = new Locale("ENGLISh","Us");
       Locale obj2 = new Locale("CHINESE","China");
     System.out.println("object obj1 of Locale class is : "+obj1);
       System.out.println("object obj2 of Locale class is : "+obj2);
     // getLanguage() method call.
         String language = obj1.getLanguage();
     System.out.println("Language code for object obj1 : " + language);
     language = obj2.getLanguage();
     System.out.println("Language code for object obj2 : " + language);
  }
}

Output of the program.
object objLocale1 of Locale class is : english_US
object objLocale2 of Locale class is : chinese_CHINA
Language code for object obj1 : english
Language code for object obj2 : chinese

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US