tags:

views:

224

answers:

2

why HashMap extends AbstractMap and implement Map ? is extending AbstractMap not sufficient, because AbstractMap implements Map?

+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
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
Except that's a breaking change - somewhere someone will have done `Map map=objectOfTypeAbstractMap`.
Software Monkey