Wednesday, November 19, 2025
HomeLanguagesJavaLocale.Category values() method in Java with Examples

Locale.Category values() method in Java with Examples

The values() method of java.util.Locale.Category enum in Java is used to get the values of the constants of this Locale.Category enum type, in the order they are declared. This method returns an array of the constants and hence can also be iterated.

Syntax:

public static Locale.Category[] values()

Parameter: This method do not accept any parameter.

Return Type: This method returns an array of the constants of this Locale.Category enum type.

Exception: This method do not throw any exception.

Program 1:




// Java program to demonstrate
// the above method
  
import java.util.*;
import java.util.Locale.*;
  
public class LocaleCategoryDemo {
    public static void main(String[] args)
    {
  
        // Getting the array of constants
        // of Locale.Category
        System.out.println("Array of constants: "
                           + Arrays.toString(
                                 Locale.Category
                                     .values()));
    }
}


Output:

Array of constants: [DISPLAY, FORMAT]

Reference: https://docs.oracle.com/javase/9/docs/api/java/util/Locale.Category.html#values–

RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32404 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6775 POSTS0 COMMENTS
Nicole Veronica
11924 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11994 POSTS0 COMMENTS
Shaida Kate Naidoo
6903 POSTS0 COMMENTS
Ted Musemwa
7159 POSTS0 COMMENTS
Thapelo Manthata
6859 POSTS0 COMMENTS
Umr Jansen
6846 POSTS0 COMMENTS