https://github.com/devrezaur/java-collections
https://github.com/devrezaur/java-collections
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/devrezaur/java-collections
- Owner: DevRezaur
- Created: 2023-09-05T03:05:19.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-07T08:03:45.000Z (about 2 years ago)
- Last Synced: 2025-03-12T03:46:39.467Z (over 1 year ago)
- Language: Java
- Size: 88.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Collections in Java
The **Collection** in Java is a framework that provides an architecture to store and manipulate the group of objects.
Java Collections can achieve all the operations that you perform on a data such as **searching, sorting, insertion,
manipulation, and deletion**.
Java Collection means a **single unit of objects**. Java Collection framework provides many interfaces such as **Set,
List, Queue, Deque** and classes such as **ArrayList, Vector, LinkedList, PriorityQueue, HashSet, LinkedHashSet,
TreeSet**.
# Java Collection Hierarchy


# ArrayList
ArrayList is a class that implements **List** interface. The ArrayList class has a **regular array** inside it. When
an element is added, it is placed into the array. If the array is not big enough, a new, larger array is created to
replace the old one and the old one is removed.
* Implements List interface
* Maintains insertion order
* Internal data structure is regular array
* Dynamic size
* Allows duplicates and any number of null values
* Can not use primitive data type (int, float, double, string)
* Best for storing and accessing data
# LinkedList
LinkedList is a class that implements **List** and **Deque** interface. The functionality and behaviour of LinkedList
class is similar to **ArrayList**. main difference is in their internal implementation. ArrayList uses regular array
and LinkedList uses actual linked list as the internal implementation.
* Implements List and Deque interface
* Maintains insertion order
* Internal data structure is doubly linked list
* Dynamic size
* Allows duplicates and any number of null values
* Cannot use primitive data type (int, float, double, string)
* Best for manipulating data
# HashMap
HashMap is a class that implements **Map** interface. The functionality and behaviour of HasMap is similar to map. That
means it doesn't allow any duplicate keys. And only one null key is accepted.
* Implements Map interface
* Doesn't insertion order
* Internal data structure is hash table
* Dynamic size
* Allows no duplicate key and only one null key
* Cannot use primitive data type (int, float, double, string)
* Best for quickly retrieving values based on particular keys
# LinkedHashMap
LinkedHashMap is a class that implements **Map** interface. The functionality and behaviour of HasMap is similar to map.
That means it doesn't allow any duplicate keys. And only one null key is accepted.
* Implements Map interface
* Maintains insertion order
* Internal data structure is hashed map and doubly linked list
* Dynamic size
* Allows no duplicate key and only one null key
* Cannot use primitive data type (int, float, double, string)
* Best for key-value pair data that needs to maintain insertion order
# HashSet
HashSet is a class that implements **Set** interface. The functionality and behaviour of HasSet is similar to set. That
means it doesn't allow any duplicates. And only one null value is accepted.
* Implements Set interface
* Doesn't maintain insertion order
* Internal data structure is hash table
* Dynamic size
* Doesn't allow duplicates and only one null value is acceptable
* Can not use primitive data type (int, float, double, string)
* Best for storing unique data
# TreeSet
TreeSet is a class that implements **NavigableSet** interface. The functionality and behaviour of TreeSet is similar to
set that maintains insertion order.
* Implements NavigableSet interface
* Doesn't insertion order
* Sorts element upon insertion
* Internal data structure is red-black tree
* Dynamic size
* Doesn't allow duplicates and null values
* Can not use primitive data type (int, float, double, string)
* Best for storing unique data while maintaining insertion order