Skip to content

Instantly share code, notes, and snippets.

@LeoHeo
Last active June 10, 2018 05:20
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 LeoHeo/503644e401bc0c71eee61bf3578e0101 to your computer and use it in GitHub Desktop.
Save LeoHeo/503644e401bc0c71eee61bf3578e0101 to your computer and use it in GitHub Desktop.
@Override
public int hashCode() {
return Objects.hash(getId());
}
Set<Student> studentSet = new HashSet<>();
studentSet.add(leo1);
studentSet.add(new Student(1L, "Leo"));
System.out.println("studentSet size => " + studentSet.size()); // studentSet size => 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment