Created
December 3, 2019 09:39
-
-
Save sangmoon/c39102b43c2c3aaf8b9c9328fb2dc63b to your computer and use it in GitHub Desktop.
equals hashcode map에 대한 과제
This file contains hidden or 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
public class SKey { | |
private int value; | |
public SKey(int value) { | |
this.value = value; | |
} | |
@Override | |
public boolean equals(Object other) { | |
return false; | |
} | |
@Override | |
public int hashCode() { | |
return 1; | |
} | |
public static void main(String[] args) { | |
Map<SKey, String> map = new HashMap<>(); | |
SKey a = new SKey(1); | |
SKey b = new SKey(2); | |
SKey c = new SKey(3); | |
map.put(a,"a"); | |
map.put(b,"b"); | |
map.put(c,"c"); | |
// 이 때 map의 상태는? | |
map.size(); | |
// 아래 호출의 return 값은? | |
map.get(a); | |
map.get(b); | |
map.get(c); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
수도 코드라 작동안할 수도 있음..