ChoiceFormat hashCode() method in Java with Examples
Last Updated :
28 Nov, 2019
The hashCode() method of java.text.ChoiceFormat class is used to get the hash code for choice format object. This hashcode value is returned as an integer.
Syntax:
public int hashCode()
Parameter: This method does not accept any parameter.
Return Value: This method returns hash code for choice format object as an integer.
Below are the examples to illustrate the hashCode() method:
Example 1:
import java.text.*;
import java.util.*;
import java.io.*;
public class GFG {
public static void main(String[] argv)
{
ChoiceFormat cf
= new ChoiceFormat(
"4#wed| 5#thu | 6#fri | 7#sat" );
int hash = cf.hashCode();
System.out.print( "hashCode :- " + hash);
}
}
|
Output:
hashCode :- 113634
Example 2:
import java.text.*;
import java.util.*;
import java.io.*;
public class GFG {
public static void main(String[] argv)
{
double [] limit = { 1 , 2 , 3 , 4 };
String[] format
= { "add" , "sub" , "multiply" , "divide" };
ChoiceFormat cf
= new ChoiceFormat(limit, format);
int hash = cf.hashCode();
System.out.print( "hashCode :- " + hash);
}
}
|
Output:
hashCode :- -1331463043
Reference: https://docs.oracle.com/javase/9/docs/api/java/text/ChoiceFormat.html#hashCode–
Share your thoughts in the comments
Please Login to comment...