Saturday, November 22, 2025
HomeLanguagesJavaResolverStyle valueOf() method in Java with Examples

ResolverStyle valueOf() method in Java with Examples

The valueOf() method of a ResolverStyle enum is used to get the enum value of this type ResolverStyle with the specified name.

Syntax:

public static ResolverStyle valueOf(String name)

Parameters: This method accepts a name as the parameter which is the name of the enum constant to be returned.

Return value: This method returns the enum constant with the specified name.

Exceptions: This method throws the following exception:

  • IllegalArgumentException: if this enum type has no constant with the specified name.
  • NullPointerException: if the argument is null.

Below programs illustrate the ResolverStyle.valueOf() method:
Program 1:




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


Output:

ResolverStyle: SMART

Program 2:




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


Output:

ResolverStyle: LENIENT

References: https://docs.oracle.com/javase/10/docs/api/java/time/format/ResolverStyle.html

RELATED ARTICLES

Most Popular

Dominic
32407 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6785 POSTS0 COMMENTS
Nicole Veronica
11932 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12000 POSTS0 COMMENTS
Shaida Kate Naidoo
6907 POSTS0 COMMENTS
Ted Musemwa
7168 POSTS0 COMMENTS
Thapelo Manthata
6864 POSTS0 COMMENTS
Umr Jansen
6852 POSTS0 COMMENTS