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