feat: Add comprehensive examples from multithreading and hashing lectures

This commit is contained in:
2026-05-24 15:46:45 +03:30
parent 6583799d9e
commit 83746b88f6
13 changed files with 314 additions and 39 deletions
+33
View File
@@ -0,0 +1,33 @@
package lecture.hash;
public class User {
private int id;
private String name;
public User(int id, String name) {
this.id = id;
this.name = name;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
User user = (User) o;
return id == user.id;
}
@Override
public int hashCode() {
return Integer.hashCode(id);
}
public static void main(String[] args) {
User u1 = new User(101, "Ali");
User u2 = new User(101, "Ali");
System.out.println("Are they logically equal? " + u1.equals(u2));
System.out.println("Do they have the same Hash? " + (u1.hashCode() == u2.hashCode()));
}
}