Java DecimalStyle hashCode()方法及实例

Java DecimalStyle hashCode()方法及实例

Java中 java.time.format.DecimalStyle类hashCode() 方法是用来获取该DecimalStyle的hashCode值。该方法返回一个代表hashCode值的整数。

语法。

public int hashCode()

参数。此方法不接受任何参数。

返回值。该方法返回一个 int值 ,即该DecimalStyle的hashCode值。

异常。此方法不抛出任何异常。

程序。

// Java program to demonstrate
// the above method
  
import java.time.format.*;
import java.util.*;
  
public class DecimalStyleDemo {
    public static void main(String[] args)
    {
  
        DecimalStyle ds1
            = DecimalStyle.STANDARD;
  
        DecimalStyle ds2
            = DecimalStyle.of(new Locale("JAPANESE"));
  
        System.out.println("HashCode value of DS 1: "
                           + ds1.hashCode());
  
        System.out.println("HashCode value of DS 2: "
                           + ds2.hashCode());
    }
}

输出:

HashCode value of DS 1: 182
HashCode value of DS 2: 182

参考资料: https://docs.oracle.com/javase/10/docs/api/java/time/format/DecimalStyle.html#hashCode()

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程