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


Java Locale.FilteringMode valueOf()用法及代碼示例


Java中java.util.Locale.FilteringMode枚舉的valueOf()方法用於獲取此Locale.FilteringMode枚舉類型的指定常量的值。此方法將常量名稱作為參數。

用法:

public static Locale.FilteringMode valueOf(String name)

參數:此方法接受參數名稱,該參數名稱是常量名稱,該常量名稱的值將從Locale.FilteringMode枚舉中檢索。


返回類型:此方法返回帶有指定名稱值的Locale.FilteringMode枚舉類型的實例。

異常:此方法不會引發任何異常。

程序1:

// Java program to demonstrate 
// the above method 
  
import java.util.*; 
import java.util.Locale.*; 
  
public class LocaleFilteringModeDemo { 
    public static void main(String[] args) 
    { 
  
        String name 
            = "AUTOSELECT_FILTERING"; 
  
        // Getting the constant 
        // of Locale.FilteringMode 
        System.out.println("Locale.FilteringMode"
                           + " value of "
                           + name + ":"
                           + Locale.FilteringMode 
                                 .valueOf(name)); 
    } 
}
輸出:
Locale.FilteringMode value of AUTOSELECT_FILTERING:AUTOSELECT_FILTERING

程序2:

// Java program to demonstrate 
// the above method 
  
import java.util.*; 
import java.util.Locale.*; 
  
public class LocaleFilteringModeDemo { 
    public static void main(String[] args) 
    { 
  
        String name 
            = "EXTENDED_FILTERING"; 
  
        // Getting the constant 
        // of Locale.FilteringMode 
        System.out.println("Locale.FilteringMode"
                           + " value of "
                           + name + ":"
                           + Locale.FilteringMode 
                                 .valueOf(name)); 
    } 
}
輸出:
Locale.FilteringMode value of EXTENDED_FILTERING:EXTENDED_FILTERING

參考: https://docs.oracle.com/javase/9/docs/api/java/util/Locale.FilteringMode.html#valueOf-java.lang.String-



相關用法


注:本文由純淨天空篩選整理自Code_r大神的英文原創作品 Locale.FilteringMode valueOf() method in Java with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。