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:
// Java program to demonstrate // TextStyle.values() method import java.time.format.TextStyle; public class GFG { public static void main(String[] args) { // get TextStyle TextStyle ts = TextStyle.valueOf( "NARROW" ); // apply values() TextStyle[] array = ts.values(); // print for ( int i = 0 ; i < array.length; i++) System.out.println(array[i]); } } |
FULL FULL_STANDALONE SHORT SHORT_STANDALONE NARROW NARROW_STANDALONE
Program 2:
// Java program to demonstrate // TextStyle.values() method import java.time.format.TextStyle; public class GFG { public static void main(String[] args) { // get TextStyle TextStyle ts = TextStyle.valueOf( "FULL_STANDALONE" ); // apply values() TextStyle[] array = ts.values(); // print System.out.println( "TextStyle length:" + array.length); } } |
TextStyle length:6
References: https://docs.oracle.com/javase/10/docs/api/java/time/format/TextStyle.html#values()