当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Java ResolverStyle values()用法及代码示例


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

用法:

public static ResolverStyle[] values()

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


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

以下示例程序旨在说明ResolverStyle.values()方法:
程序1:

// 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

程序2:

// 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://docs.oracle.com/javase/10/docs/api/java/time/format/ResolverStyle.html



相关用法


注:本文由纯净天空筛选整理自AmanSingh2210大神的英文原创作品 ResolverStyle values() method in Java with Examples。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。