What is the difference between collection and set




















If you have a set of something, there are a certain amount of pieces, and you need them all to complete the set. With a collection, you are just trying to get as many as possible. See a translation. Thank you very much! Sorry it sent 4 times, there was a problem with the app! No problem and again, thank you! The one learning a language!

Learn about premium features. In this respect, using "set" instead of "collection" will leave a more "mathematical" taste in the mouth of many readers. But if history would have a quirk and "collection" would be the "mathematical" word, I'd have interchanged the two in this answer.

It's a matter of definitions, and to some extent arbitrary. Sign up to join this community. The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Learn more. Ask Question. Asked 8 years, 1 month ago. Active 8 years, 1 month ago. Viewed 7k times. Look at both the types and the methods defined upon such, as well as the constraints: "The Set interface places additional stipulations, beyond those inherited from the Collection interface, on the contracts of all constructors and on the contracts of the add, equals and hashCode methods.

Declarations for other inherited methods are also included here for convenience. The specifications accompanying these declarations have been tailored to the Set interface, but they do not contain any additional stipulations.

Its not always about the methods; having a Set interface, you can state in an API that you expect or return a Set and not an arbitrary Collection. Add a comment. Active Oldest Votes. The Set Interface Note, Set does not preserve the order in which elements were inserted.

Yan Khonski Yan Khonski 9, 13 13 gold badges 55 55 silver badges 92 92 bronze badges. I guess I kind of understood what you want to know exactly. Sudhir Dhumal Sudhir Dhumal 6 6 silver badges 19 19 bronze badges.

Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Does ES6 make JavaScript frameworks obsolete? Podcast Do polyglots have an edge when it comes to mastering programming Featured on Meta.



0コメント

  • 1000 / 1000