-Integer literals are int type -Map will be treated as nonexistent if the key type is different (even if there is a value that seems to be guessed by the cast)
import java.util.*;
public class MapTest {
public static void main(String[] argv) {
Map<Short, Object> a = new HashMap<>();
a.put(new Short("1"), new Object());
System.out.println(a); // {1=java.lang.Object@7852e922}
System.out.println(a.get(1)); // null !!
System.out.println(a.get(new Short("1"))); // java.lang.Object@7852e922
}
}
Recommended Posts