Last active
June 10, 2018 03:31
-
-
Save LeoHeo/e769b1e651ca43f4531868d7fe4500ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.github.leoheo.equals; | |
/** | |
* @author Heo, Jin Han | |
* @since 2018-06-10 | |
*/ | |
public class Student { | |
private Long id; | |
private String name; | |
public Student(Long id, String name) { | |
this.id = id; | |
this.name = name; | |
} | |
public Long getId() { | |
return id; | |
} | |
public void setId(Long id) { | |
this.id = id; | |
} | |
public String getName() { | |
return name; | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.github.leoheo.equals; | |
public class Main { | |
public static void main(String[] args) { | |
Student leo1 = new Student(1L, "Leo"); | |
Student leo2 = new Student(1L, "Leo"); | |
System.out.println("leo1 hashcode => " + leo1.hashCode()); // 1625635731 | |
System.out.println("leo2 hashcode => " + leo2.hashCode()); // 1580066828 | |
System.out.println("leo1.equals(leo2) => " + leo1.equals(leo2)); // false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment