ResolverStyle values() method in Java with Examples
Last Updated :
24 Apr, 2023
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
import java.time.format.ResolverStyle;
public class GFG {
public static void main(String[] args)
{
ResolverStyle resolverStyle
= ResolverStyle.valueOf(" SMART & quot;);
ResolverStyle[] array = resolverStyle.values();
for ( int i = 0 ; i & lt; array.length; i++)
System.out.println(array[i]);
}
}
|
Output:
STRICT
SMART
LENIENT
Program 2:
Java
import java.time.format.ResolverStyle;
public class GFG {
public static void main(String[] args)
{
ResolverStyle resolverStyle
= ResolverStyle.valueOf(" LINIENT & quot;);
ResolverStyle[] array = resolverStyle.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
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...