Java Locale - hashCode() Method
The java.util.Locale.hashCode() method returns a hash code for this Locale.
Syntax
public int hashCode()
Parameters
No parameter is required.
Return Value
Returns a hash code value for this locale.
Exception
NA
Example:
In the example below, the java.util.Locale.hashCode() method is used to get the hash code for the given Locale object.
import java.util.*; public class MyClass { public static void main(String[] args) { //creating a locale Locale loc = new Locale("EN", "UK"); //printing the locale System.out.println("loc is: " + loc); //printing the hashcode for the locale System.out.println("hashCode is: " + loc.hashCode()); } }
The output of the above code will be:
loc is: en_UK hashCode is: 96636641
❮ Java.util - Locale