mirror of
https://github.com/krahets/hello-algo.git
synced 2026-04-08 21:32:15 +08:00
translation: Add Python and Java code for EN version (#1345)
* Add the intial translation of code of all the languages * test * revert * Remove * Add Python and Java code for EN version
This commit is contained in:
38
en/codes/java/chapter_hashing/built_in_hash.java
Normal file
38
en/codes/java/chapter_hashing/built_in_hash.java
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user