s-day02-HashSet存储自定义对象

This commit is contained in:
2026-08-02 11:53:48 +08:00
parent 648800a600
commit 9f74cb1cae
3 changed files with 38 additions and 4 deletions
@@ -17,10 +17,10 @@ public class HashTableDemo09 {
String str3 = "通话";
String str4 = "重地";
//查看他们各自的哈希值
System.out.println(str1.hashCode());
System.out.println(str2.hashCode());
System.out.println(str3.hashCode());
System.out.println(str4.hashCode());
System.out.println(str1.hashCode());//96354
System.out.println(str2.hashCode());//96354
System.out.println(str3.hashCode());//1179395
System.out.println(str4.hashCode());//1179395
//存入set集合
HashSet<String> sets = new HashSet<>();