Below is the list of Standard Data Structures provided in the Java Programming Langauge.
Array:
Array data structure is a fixed-size collection of elements of the same data type that can be accessed using index values. Arrays are efficient for accessing elements by index but inefficient for inserting or deleting elements in the middle of the array.
- Hierarchy: N/A
- Access Time (worst case): O(1)
- Search Time (worst case): O(n)
- Insertion Time (worst case): O(n)
- Deletion Time (worst case): O(n)
- Thread-safety: Not thread-safe
ArrayList:
ArrayList Data Structure is a dynamic array in Java that can grow or shrink during runtime.
- Hierarchy: List
- Access Time (worst case): O(1)
- Search Time (worst case): O(n)
- Insertion Time (worst case): O(n)
- Deletion Time (worst case): O(n)
- Thread-safety: Not thread-safe
LinkedList:
LinkedList is a data structure that stores a collection of elements, where each element has a reference to the next element in the list.
- Hierarchy: List
- Access Time (worst case): O(n)
- Search Time (worst case): O(n)
- Insertion Time (worst case): O(1)
- Deletion Time (worst case): O(1)
- Thread-safety: Not thread-safe
Stack:
Stack is a last-in, first-out (LIFO) data structure that allows elements to be pushed onto and popped off of the top of the stack.
- Hierarchy: List
- Access Time (worst case): O(n)
- Search Time (worst case): O(n)
- Insertion Time (worst case): O(1)
- Deletion Time (worst case): O(1)
- Thread-safety: Not thread-safe
Queue:
A queue is a linear data structure, based on FIFO (First In First Out) principle, elements are inserted from one end called the rear, and removed from the other end called the front.
- Hierarchy: List
- Access Time (worst case): O(n)
- Search Time (worst case): O(n)
- Insertion Time (worst case): O(1)
- Deletion Time (worst case): O(1)
- Thread-safety: Not thread-safe
PriorityQueue:
PriorityQueue is a data structure that orders elements based on their priority, which is determined by a Comparator or the natural ordering of elements.
- Hierarchy: Queue
- Access Time (worst case): O(n)
- Search Time (worst case): O(n)
- Insertion Time (worst case): O(log n)
- Thread-safety: Not thread-safe
Set:
Set data structure is a collection of unique elements that does not allow duplicate values.
- Hierarchy: N/A
- Access Time (worst case): N/A
- Search Time (worst case): O(log n)
- Insertion Time (worst case): O(log n)
- Deletion Time (worst case): O(log n)
- Thread-safety: Not thread-safe
HashSet:
HashSet is a very popular data structure in which the elements are stored using a hash table.
- Hierarchy: Set
- Access Time (worst case): O(1)
- Search Time (worst case): O(1)
- Insertion Time (worst case): O(1)
- Deletion Time (worst case): O(1)
- Thread-safety: Not thread-safe
TreeSet:
TreeSet is an ordered, sorted collection of data based mostly on the red-black tree data structure to maintain the elements in sorted order.
- Hierarchy: Set
- Access Time (worst case): O(log n)
- Search Time (worst case): O(log n)
- Insertion Time (worst case): O(log n)
- Deletion Time (worst case): O(log n)
- Thread-safety: Not thread-safe
Some more Data Structures from Java Collections Framework (up to Java 17)
EnumSet
ArrayDeque
ConcurrentHashMap
CopyOnWriteArrayList
CopyOnWriteArraySet
DelayQueue
EnumMap
IdentityHashMap
LinkedHashMap
LinkedBlockingDeque
LinkedBlockingQueue
PriorityBlockingQueue
TreeMap
WeakHashMap
ConcurrentSkipListSet
ConcurrentSkipListMap
ArrayBlockingQueue
BitSet
Have Questions? Post them here!
- Create a Zip file using Java Code programmatically
- Eclipse : A java Runtime Environment (JRE) or Java Development kit (JDK) must be available
- How to Sort a LinkedList in Java
- Loading class com.mysql.jdbc.Driver. This is deprecated. The new driver class is com.mysql.cj.jdbc.Driver
- How to declare and initialize Array in Java Programming
- [Fix] java: integer number too large compilation error
- Java JDBC Connection with MySQL Driver in VS Code + Troubleshooting
- Reading .xls and .xlsx Excel file using Apache POI Java Library
- IntelliJ: Error: Could not find or load main class, java.lang.ClassNotFoundException
- How to get Client IP address using Java Code Example
- Truncate table using Java JDBC Example
- Struts 2 : There is no Action mapped for namespace [/] and action name [form] associated with context path [/proj]
- How to get file path in Idea IntelliJ IDE
- Java Generics explained with simple definition and examples
- Java SE 8 Update 301 available with various bug fixes and security improvements
- Java: Collect Stream as ArrayList or LinkedList
- Java JDBC Connection with PostgreSQL Driver Example
- How to check if Java main thread is alive
- How to fix Java nio NoSuchFileException wile reading a file
- Java 8+ get Day of the Week Examples with LocalDateTime, DateTime, ZonalDateTime and Instant classes
- Ways to Convert Integer or int to Long in Java
- [Java] How to throws Exception using Functional Interface and Lambda code
- [Fix] Spring Boot: mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
- Java: The value of the local variable string is not used
- Java JDBC: Insert Java 8 LocalDate and Time using PreparedStatement
- Eclipse version 32-bit or 64-bit check on macOS - Eclipse
- Float built-in function in Python - Python
- Android Studio emulator/Device logCat logs not displayed - Android-Studio
- Error: Can not find the tag library descriptor for - Java
- Exception in thread main java.lang.NoClassDefFoundError: package javaClass - Java
- How to set background color for android layout pragmatically using java and through xml - Android
- Android Studio Error: Default Activity not found - Android-Studio
- Create Nested Directories using Java Code - Java