Difference between Collection Interface Set Interface

Difference between Collection Interface Set Interface

Answer: Below are difference:

Collection Interface Set Interface
Collection interface represents the group of objects which is known by its elements. Set interface is Collection that cannot contain duplicate elements.
Collection extends Iterable interface (public interface Collection<E>

extends Iterable<E>)

Whereas Set extends Collection interface (public interface Set<E> extends Collection<E>)
Collection is top level interface which works on group of objects and less precise Because Set extends Collection so it’s more specific
Both has same method but return value has different meanings Both has same method but return value has different meanings

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *