java.text.ChoiceFormat類的hashCode()方法用於獲取選擇格式對象的哈希碼。此哈希碼值以整數形式返回。
用法:
public int hashCode()
參數:此方法不接受任何參數。
返回值:此方法以整數形式返回選擇格式對象的哈希碼。
下麵是說明hashCode()方法的示例:
示例1:
// Java program to demonstrate hashCode() method
import java.text.*;
import java.util.*;
import java.io.*;
public class GFG {
public static void main(String[] argv)
{
// creating and initializing ChoiceFormat
ChoiceFormat cf
= new ChoiceFormat(
"4#wed| 5#thu | 6#fri | 7#sat");
// getting hashcode of ChoiceFormat object
// using hashCode() method
int hash = cf.hashCode();
// display the result
System.out.print("hashCode :- " + hash);
}
}
輸出:
hashCode :- 113634
示例2:
// Java program to demonstrate hashCode() method
import java.text.*;
import java.util.*;
import java.io.*;
public class GFG {
public static void main(String[] argv)
{
// creating and initializing limit
double[] limit = { 1, 2, 3, 4 };
// creating and initializing format
String[] format
= { "add", "sub", "multiply", "divide" };
// creating and initializing ChoiceFormat
ChoiceFormat cf
= new ChoiceFormat(limit, format);
// getting hashcode of ChoiceFormat object
// using hashCode() method
int hash = cf.hashCode();
// display the result
System.out.print("hashCode :- " + hash);
}
}
輸出:
hashCode :- -1331463043
參考: https://docs.oracle.com/javase/9/docs/api/java/text/ChoiceFormat.html#hashCode–
相關用法
- Java ChoiceFormat equals()用法及代碼示例
- Java ChoiceFormat setChoices()用法及代碼示例
- Java ChoiceFormat parse()用法及代碼示例
- Java ChoiceFormat previousDouble()用法及代碼示例
- Java ChoiceFormat applyPattern()用法及代碼示例
- Java ChoiceFormat format()用法及代碼示例
- Java ChoiceFormat getLimits()用法及代碼示例
- Java ChoiceFormat getFormats()用法及代碼示例
- Java ChoiceFormat nextDouble(double)用法及代碼示例
- Java ChoiceFormat nextDouble(double, boolean)用法及代碼示例
- Java Set hashCode()用法及代碼示例
- Java Map hashCode()用法及代碼示例
- Java Charset hashCode()用法及代碼示例
- Java LocalDate hashCode()用法及代碼示例
- Java Optional hashCode()用法及代碼示例
注:本文由純淨天空篩選整理自RohitPrasad3大神的英文原創作品 ChoiceFormat hashCode() method in Java with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。