Skip to content

Instantly share code, notes, and snippets.

@raviyasas
Created September 15, 2022 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raviyasas/adbb11095eb41ef3016ebbf2897491c2 to your computer and use it in GitHub Desktop.
Save raviyasas/adbb11095eb41ef3016ebbf2897491c2 to your computer and use it in GitHub Desktop.
public class Employee{
private int id;
private String employeeName;
public Employee(int id) {
this.id= id;
}
//getters and setters
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + id;
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Employee other = (Employee) obj;
if (id!= other.id)
return false;
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment