Why doesn't Java Map extends Collection?

Posted by polygenelubricants on Stack Overflow See other posts from Stack Overflow or by polygenelubricants
Published on 2010-04-16T09:17:21Z Indexed on 2010/04/16 9:23 UTC
Read the original article Hit count: 184

I was surprised by the fact that Map<?,?> is not a Collection<?>.

I thought it'd make a LOT of sense if it was declared as such:

public interface Map<K,V> extends Collection<Map.Entry<K,V>>

After all, a Map<K,V> is a collection of Map.Entry<K,V>, isn't it?

So is there a good reason why it's not implemented as such?

© Stack Overflow or respective owner

Related posts about java

Related posts about collections