Files
hello-algo/en/codes/java/chapter_hashing/built_in_hash.java
Yudong Jin 14c314c08c Retranslate the complete English edition from Simplified Chinese (#2010)
* Retranslate the complete English edition from Simplified Chinese

* Polish three English explanations after reader-focused review
2026-10-31 03:35:51 +08:00

39 lines
1.2 KiB
Java

/**
* File: built_in_hash.java
* Created Time: 2023-06-21
* Author: krahets (krahets@163.com)
*/
package chapter_hashing;
import utils.*;
import java.util.*;
public class built_in_hash {
public static void main(String[] args) {
int num = 3;
int hashNum = Integer.hashCode(num);
System.out.println("Integer " + num + " has hash value " + hashNum);
boolean bol = true;
int hashBol = Boolean.hashCode(bol);
System.out.println("Boolean " + bol + " has hash value " + hashBol);
double dec = 3.14159;
int hashDec = Double.hashCode(dec);
System.out.println("Decimal " + dec + " has hash value " + hashDec);
String str = "Hello 算法";
int hashStr = str.hashCode();
System.out.println("String " + str + " has hash value " + hashStr);
Object[] arr = { 12836, "小哈" };
int hashTup = Arrays.hashCode(arr);
System.out.println("Array " + Arrays.toString(arr) + " has hash value " + hashTup);
ListNode obj = new ListNode(0);
int hashObj = obj.hashCode();
System.out.println("Node object " + obj + " has hash value " + hashObj);
}
}