Timeline for Map with different types for values
Current License: CC BY-SA 3.0
3 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Nov 2, 2014 at 18:11 | comment | added | toto2 |
Return null if map.get(key) is null, otherwise your api is broken. If you have a public method that can trigger a NullPointerException, that's not good.
|
|
| Nov 2, 2014 at 18:08 | comment | added | res1 | I know that about the null pointer exception that can occur, but in my real case i will always call contains() before get() but anyway it's better to put a check there. Why you said that is complicated ? once you created the map you use cache.get(key, clazz) or cache.put(key, clazz, value) | |
| Nov 2, 2014 at 17:47 | history | answered | toto2 | CC BY-SA 3.0 |