Java.util.Locale.hashCode() Method

Advertisements


Description

The java.util.Locale.hashCode() method returns a hash code for this locale.

Declaration

Following is the declaration for java.util.Locale.hashCode() method

public int hashCode()

Parameters

  • NA

Return Value

This method returns a hash code value for this object.

Exception

  • NA

Example

The following example shows the usage of java.util.Locale.hashCode() method.

package com.tutorialspoint;

import java.util.*;

public class LocaleDemo {

   public static void main(String[] args) {

      // create a new locale
      Locale locale = new Locale("en", "US", "WIN");

      // print locale
      System.out.println("Locale:" + locale);

      // get a hash code and print it
      System.out.println("Language:" + locale.hashCode());
   }
}

Let us compile and run the above program, this will produce the following result:

Locale:en_US_WIN
Language:1595486



Advertisements
Advertisements