Java Locale getVariant() method

7 Nov 2024 | 1 min read

The getVaiant() method of Java Locale class is used to return the variant code for this locale.

Syntax

Parameter

NA

Return

This method returns the variant code. If none is defined, this method will return an empty string.

Example 1

Output:

Locale: english_IN_IND Variant name: IND 

Example 2

Output:

Locale1: english_IN_IND Locale2: english_IN_IND Variant of locale1: IND Variant of locale2: WIN