Collection framework in java

Need of collection framework

Why do we need a collection framework in java?.

Hierarchy of collection framework.

Which collection interface and classes should we use.

  1. Order: sometimes we need order and sometimes we don't need items to be stored in a specific order.
  2. Duplicates: Sometimes it is okay to have duplicates and sometimes duplicates are strictly prohibited.
  3. Speed of Operation: We perform different operations on data. Some algorithms are fast at searching data, some are good at adding data.
  4. Memory: Some collections consume high memory, some consume less memory. we should keep in mind while choosing the collection.

List implementation.

  1. ArrayList: It is used to implement a dynamic version of the array. It supports data searching and manipulation by index. Duplicates are allowed in the ArrayList.
  2. CopyOnWriteArrayList: This is synchronized version of arraylist.
  3. LinkedList: This is the implementation of the doubly linked list data structure.In which each node stores data and a reference to the next and previous node.LinkedList is very good if we want deletion, insertion of an element in the middle of the list.
  4. Vector: Vector class is dynamic array implementation of the array, the only difference is this is thread-safe.
  5. Stack: Stack in java is the child class of Vector. This is based on the principle of last-in and first-out (LIFO).

Queue and Deque implementation

Set implementation.

Map implementation in java.

Comparator and Comparable.

Iterable, Iterator and ListIterator.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aditya Kumar

Hi, I am Aditya. I studied at IIT BHU Varanasi , India. I am a Java developer. I partricipate in competitive programming.