Java Locale getVariant() Example

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


Syntax is : public String getVariant()
Method returns the variant code for this locale.

Here is the code.

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

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

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

Output of the program.
object objLocale1 of Locale class is : english_US_WIN
object objLocale2 of Locale class is : chinese_CHINA_MAC
Variant code for object obj1 : WIN
Variant code for object obj2 : MAC

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

HOME | COPYRIGHT | CONTACT US