Java.util.Locale.hashCode() 方法

描述

java.util.Locale.hashCode() 方法返回此语言环境的哈希码。


声明

以下是 java.util.Locale.hashCode() 方法的声明

public int hashCode()

参数

NA


返回值

此方法返回此对象的哈希码值。


异常

NA


示例

下面的例子展示了 java.util.Locale.hashCode() 方法的使用。

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());
   }
}

让我们编译并运行上面的程序,这将产生以下结果 −

Locale:en_US_WIN
Language:1595486