Java中的Locale类的hashCode()方法用于返回此语言环境的哈希码。
用法:
LOCALE.hashCode()
参数:此方法不带任何参数。
返回值:此方法返回给定语言环境的哈希码值。
以下示例程序旨在说明hashCode()方法的用法:
示例1:
// Java code to illustrate hashCode() method
import java.util.*;
public class Locale_Demo {
public static void main(String[] args)
{
// Creating a new locale
Locale first_locale
= new Locale("nu", "NO", "NY");
// Displaying first locale
System.out.println("First Locale: "
+ first_locale);
// Displaying the hash_code of this locale
System.out.println("The Hash Code: "
+ first_locale.hashCode());
}
}
输出:
First Locale: nu_NO_NY The Hash Code: 105152771
示例2:
// Java code to illustrate hashCode() method
import java.util.*;
public class Locale_Demo {
public static void main(String[] args)
{
// Creating a new locale
Locale first_locale
= new Locale("ar", "SA");
// Displaying first locale
System.out.println("First Locale: "
+ first_locale);
// Displaying the hash_code of this locale
System.out.println("The Hash Code: "
+ first_locale.hashCode());
}
}
输出:
First Locale: ar_SA The Hash Code: 93059489
相关用法
- Java TimeZone getDisplayName(Locale locale)用法及代码示例
- Java Locale getDisplayVariant(Locale inLoc)用法及代码示例
- Java Locale.Builder setLocale(Locale)用法及代码示例
- Java Locale getDisplayCountry(Locale)用法及代码示例
- Java Locale getDisplayLanguage(Locale)用法及代码示例
- Java Locale getDisplayName(Locale)用法及代码示例
- Java Formatter locale()用法及代码示例
- Java Locale toString()用法及代码示例
- Java Locale toLanguageTag()用法及代码示例
- Java Locale getExtensionKeys()用法及代码示例
- Java Locale clone()用法及代码示例
- Java Locale setDefault()用法及代码示例
- Java Locale getVariant()用法及代码示例
- Java Locale getDisplayCountry()用法及代码示例
注:本文由纯净天空筛选整理自Chinmoy Lenka大神的英文原创作品 Locale hashCode() Method in Java with Examples。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。