why HashMap extends AbstractMap and implement Map ? is extending AbstractMap not sufficient, because AbstractMap implements Map?
views:
224answers:
2
+3
A:
It is redundant. I suspect that it was done for "documentation" reasons. HashMap implements Map, and you can rely on that. The fact that it extends AbstractMap is arguably just an implementation detail. (Though it's extremely unlikely that future versions of HashMap would not extend AbstractMap, since there probably some code out there that expects HashMap to be assignable to AbstractMap.)
Laurence Gonsalves
2010-02-19 06:48:00
A:
It is redundant, but doesn't hurt. If they do not want to implement Map
in AbstractMap
in future, it will still work.
fastcodejava
2010-02-19 07:14:45
Except that's a breaking change - somewhere someone will have done `Map map=objectOfTypeAbstractMap`.
Software Monkey
2010-02-19 08:26:56