Sunday, February 22, 2026
HomeLanguagesJavaResolverStyle values() method in Java with Examples

ResolverStyle values() method in Java with Examples

The values() method of ResolverStyle enum is used to an array containing the units of this ResolverStyle, in the order, they are declared. 

Syntax:

public static ResolverStyle[] values()

Parameters: This method accepts nothing. 

Return value: This method returns an array containing the constants of this enum type, in the order, they are declared. Below programs illustrate the ResolverStyle.values() method:

Program 1: 

Java




// Java program to demonstrate
// ResolverStyle.values() method
 
import java.time.format.ResolverStyle;
 
public class GFG {
   
    public static void main(String[] args)
    {
 
        // Get ResolverStyle instance
        ResolverStyle resolverStyle
            = ResolverStyle.valueOf(" SMART & quot;);
 
        // Get the constants using values()
        ResolverStyle[] array = resolverStyle.values();
 
        // Print the values
        for (int i = 0; i & lt; array.length; i++)
            System.out.println(array[i]);
    }
}


Output:

STRICT
SMART
LENIENT

Program 2: 

Java




// Java program to demonstrate
// ResolverStyle.values() method
 
import java.time.format.ResolverStyle;
 
public class GFG {
   
    public static void main(String[] args)
    {
 
        // Get ResolverStyle instance
        ResolverStyle resolverStyle
            = ResolverStyle.valueOf(" LINIENT & quot;);
 
        // Get the constants using values()
        ResolverStyle[] array = resolverStyle.values();
 
        // Print the values
        System.out.println(" ResolverStyle length
                           : "
                           + array.length);
    }
}


Output:

ResolverStyle length: 3

Example:

Java




package abc;
 
import java.io.*;
import java.time.format.ResolverStyle;
import java.util.Scanner;
 
public class as {
    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);
        System.out.print(
            "Enter a resolver style (smart, strict, lenient): ");
        String input = scanner.nextLine().toLowerCase();
        ResolverStyle style = null;
        switch (input) {
        case "smart":
            style = ResolverStyle.SMART;
            break;
        case "strict":
            style = ResolverStyle.STRICT;
            break;
        case "lenient":
            style = ResolverStyle.LENIENT;
            break;
        default:
            System.out.println("Invalid input.");
            System.exit(0);
        }
        System.out.println("Resolver Style: " + style);
    }
}


Output:

Enter a resolver style (smart, strict, lenient): strict
Resolver Style: STRICT
RELATED ARTICLES

Most Popular

Dominic
32506 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6882 POSTS0 COMMENTS
Nicole Veronica
12005 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12099 POSTS0 COMMENTS
Shaida Kate Naidoo
7011 POSTS0 COMMENTS
Ted Musemwa
7255 POSTS0 COMMENTS
Thapelo Manthata
6967 POSTS0 COMMENTS
Umr Jansen
6956 POSTS0 COMMENTS