FormatStyle values() method in Java with Examples
Last Updated :
18 Aug, 2021
The values() method of FormatStyle enum is used to an array containing the units of this FormatStyle, in the order, they are declared.
Syntax:
public static FormatStyle[] 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 FormatStyle.values() method:
Program 1:
Java
import java.time.format.FormatStyle;
public class GFG {
public static void main(String[] args)
{
FormatStyle formatStyle
= FormatStyle.valueOf( "FULL" );
FormatStyle[] array
= formatStyle.values();
for ( int i = 0 ; i < array.length; i++)
System.out.println(array[i]);
}
}
|
Output:
FULL
LONG
MEDIUM
SHORT
Program 2:
Java
import java.time.format.FormatStyle;
public class GFG {
public static void main(String[] args)
{
FormatStyle formatStyle
= FormatStyle.valueOf( "FULL" );
FormatStyle[] array
= formatStyle.values();
System.out.println( "FormatStyle length: "
+ array.length);
}
}
|
Output:
FormatStyle length: 4
References: https://docs.oracle.com/javase/10/docs/api/java/time/format/FormatStyle.html
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...