ResolverStyle valueOf() method in Java with Examples
Last Updated :
04 Feb, 2020
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:
import java.time.format.ResolverStyle;
public class GFG {
public static void main(String[] args)
{
ResolverStyle resolverStyle
= ResolverStyle.valueOf( "SMART" );
System.out.println( "ResolverStyle: "
+ resolverStyle);
}
}
|
Output:
ResolverStyle: SMART
Program 2:
import java.time.format.ResolverStyle;
public class GFG {
public static void main(String[] args)
{
ResolverStyle resolverStyle
= ResolverStyle.valueOf( "LENIENT" );
System.out.println( "ResolverStyle: "
+ resolverStyle);
}
}
|
Output:
ResolverStyle: LENIENT
References: https://docs.oracle.com/javase/10/docs/api/java/time/format/ResolverStyle.html
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...