Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Collection and Container

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.

like image 325
questions Avatar asked Mar 04 '12 06:03

questions


People also ask

What is container collection?

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.

Is Collection same as list?

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.

What's the difference between collection and collections in Java?

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.


1 Answers

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.

like image 65
Louis Wasserman Avatar answered Sep 30 '22 10:09

Louis Wasserman