mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-28 06:36:30 +08:00
1c0f350ad6
* Add the intial translation of code of all the languages * test * revert * Remove * Add Python and Java code for EN version
38 lines
1.2 KiB
Java
38 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("The hash value of integer " + num + " is " + hashNum);
|
|
|
|
boolean bol = true;
|
|
int hashBol = Boolean.hashCode(bol);
|
|
System.out.println("The hash value of boolean " + bol + " is " + hashBol);
|
|
|
|
double dec = 3.14159;
|
|
int hashDec = Double.hashCode(dec);
|
|
System.out.println("The hash value of decimal " + dec + " is " + hashDec);
|
|
|
|
String str = "Hello algorithm";
|
|
int hashStr = str.hashCode();
|
|
System.out.println("The hash value of string " + str + " is " + hashStr);
|
|
|
|
Object[] arr = { 12836, "Ha" };
|
|
int hashTup = Arrays.hashCode(arr);
|
|
System.out.println("The hash value of array " + Arrays.toString(arr) + " is " + hashTup);
|
|
|
|
ListNode obj = new ListNode(0);
|
|
int hashObj = obj.hashCode();
|
|
System.out.println("The hash value of node object " + obj + " is " + hashObj);
|
|
}
|
|
}
|