-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHashCodeTest.java
More file actions
38 lines (33 loc) · 904 Bytes
/
HashCodeTest.java
File metadata and controls
38 lines (33 loc) · 904 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package BasicAndDontKnow;
public class HashCodeTest {
/**
* @param args
*/
public static void main(String[] args) {
String b="1";
System.out.println(+b.hashCode());
System.out.println("myhashCode:");
System.out.println(myhashCode(b.toCharArray()));
int i=0;
char c='陈';
int f=0+c;
System.out.println("f:"+c);
}
public static int myhashCode(char[] value){
int h=0;
if (h == 0 && value.length > 0) {
char val[] = value;
for(char c:val){
System.out.println(c);
}
for (int i = 0; i < value.length; i++) {
System.out.println("h:"+h);
System.out.println("val[i]:"+val[i]);
System.out.println("31 * h + val[i]:"+31 * h + val[i]);
h = 31 * h + val[i];
System.out.println("hhhhhhh"+h);
}
}
return h;
}
}