直接上代码:
package com.hao.test;
import java.util.LinkedList;
import java.util.List;
public class Test {
public static void main(String[] args) {
String str1 = "精彩";
String str2 = "精彩";
System. out. println("哈希值");
System. out. println(String. format("str1:%d | str2:%d", str1. hashCode(),str2. hashCode()));
System. out. println(str1. equals(str2));
List<String> list=new LinkedList<>();
List<String> list2=new LinkedList<>();
list.add("dd");
list.add("sss");
list.add("d");
list2.add("dd");
list2.add("sss");
System.out.println(list);
list.addAll(list2);//并集-赋值到list中
System.out.println(list);
list.retainAll(list2);//交集-赋值到list中
System.out.println(list);
get();
}
//得到hash相同的内容
public static void get(){
for (int i = 1014379; i <= 1014379; i++) {
for (int j = 19968; j <= 40869; j++) {
for (int m = 19968; m <= 40869; m++) {
if (i == 31 * j + m) {
System.out.println((char) j + "" + (char) m);
}
}
}
}
}
}