📜  Java中的 ResolverStyle values() 方法及示例

📅  最后修改于: 2022-05-13 01:55:51.059000             🧑  作者: Mango

Java中的 ResolverStyle values() 方法及示例

ResolverStyle 枚举values()方法用于包含此 ResolverStyle 的单元的数组,按顺序声明它们。

句法:

public static ResolverStyle[] values()

参数:此方法不接受任何内容。

返回值:此方法返回一个包含此枚举类型的常量的数组,按顺序声明它们。

下面的程序说明了 ResolverStyle.values() 方法:
方案一:

// Java program to demonstrate
// ResolverStyle.values() method
  
import java.time.format.ResolverStyle;
  
public class GFG {
    public static void main(String[] args)
    {
  
        // Get ResolverStyle instance
        ResolverStyle resolverStyle
            = ResolverStyle.valueOf("SMART");
  
        // Get the contants using values()
        ResolverStyle[] array
            = resolverStyle.values();
  
        // Print the values
        for (int i = 0; i < array.length; i++)
            System.out.println(array[i]);
    }
}
输出:
STRICT
SMART
LENIENT

方案二:

// Java program to demonstrate
// ResolverStyle.values() method
  
import java.time.format.ResolverStyle;
  
public class GFG {
    public static void main(String[] args)
    {
  
        // Get ResolverStyle instance
        ResolverStyle resolverStyle
            = ResolverStyle.valueOf("LINIENT");
  
        // Get the contants using values()
        ResolverStyle[] array
            = resolverStyle.values();
  
        // Print the values
        System.out.println("ResolverStyle length: "
                           + array.length);
    }
}
输出:
ResolverStyle length: 3

参考资料:https: Java