I am little confused about the difference between containers and collections. I read about them on Wikipedia and this is what I have understood..
Collections : Stores variable number of objects. Ex. list, set...
Containers : DataStructures? Ex. dequeue, stack..
But I thought collections like list, tree etc are data structures, then what are containers. Also what does this mean..
Data structures that implement containers include arrays, lists, maps, queues, sets, stacks, tables, trees, and vectors.
What Does Collection Container Mean? A collection container is a vessel, such as a cup or vial, used to hold the biological sample being collected for lab testing. A collection container may be used to hold a blood, oral fluid, urine, hair or other samples.
In List, data is in particular order. In Set, it can not contain the same data twice. In Collection, it just stores data with no particular order and can contain duplicate data.
So in Java, Collection and Collections are not at all the same thing. Collection is the interface where you group objects into a single unit. Collections is a utility class that has some set of operations you perform on Collection.
Java doesn't really use the term "container," except in the context of AWT GUI components, in which a Container
represents a GUI component that can contain other components.
Collection
is used in Java for data structures that contain objects, as you describe.
Computer science in general tends to treat them as more or less synonymous.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With