當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。