What is the difference between Collection and Set interfaces in Java? -
If the declared method signatures begin to be the same, then what is the purpose of setting up the set interface, rather than applying the collection directly? Or is it just a marker interface? set guarantees that the unique element in the collection (no duplicates) A archive will not guarantee it. The only methods inherited from the set interface collection are included and the copy adds that duplicate elements are prohibited. The set also adds a strong contract to the behavior of equal and hashode functions, even if the set allows examples to compare meaningfully, even if Their implementation type is different. Two set examples are the same if they are the same elements. Note, set does not preserve the order in which the elements were inserted. You LinkedHashSet if you need to preserve the entry order of elements