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
Facing issues? Have Questions? Post them here! I am happy to answer!
Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.
Follow him on: X
You can also reach out to him via e-mail: rakesh@code2care.org
- Get the current timestamp in Java
- Java Stream with Multiple Filters Example
- Java SE JDBC with Prepared Statement Parameterized Select Example
- Fix: UnsupportedClassVersionError: Unsupported major.minor version 63.0
- [Fix] Java Exception with Lambda - Cannot invoke because object is null
- 7 deadly java.lang.OutOfMemoryError in Java Programming
- How to Calculate the SHA Hash Value of a File in Java
- Java JDBC Connection with Database using SSL (https) URL
- How to Add/Subtract Days to the Current Date in Java
- Create Nested Directories using Java Code
- Spring Boot: JDBCTemplate BatchUpdate Update Query Example
- What is CA FE BA BE 00 00 00 3D in Java Class Bytecode
- Save Java Object as JSON file using Jackson Library
- Adding Custom ASCII Text Banner in Spring Boot Application
- [Fix] Java: Type argument cannot be of primitive type generics
- List of New Features in Java 11 (JEPs)
- Java: How to Add two Maps with example
- Java JDBC Transition Management using PreparedStatement Examples
- Understanding and Handling NullPointerException in Java: Tips and Tricks for Effective Debugging
- Steps of working with Stored Procedures using JDBCTemplate Spring Boot
- Java 8 java.util.Function and BiFunction Examples
- The Motivation Behind Generics in Java Programming
- Get Current Local Date and Time using Java 8 DateTime API
- Java: Convert Char to ASCII
- Deep Dive: Why avoid java.util.Date and Calendar Classes
- [fix] Java JDBC SQLSyntaxErrorException: Unknown database - Java
- How to fix: zsh: command not found: jupyter - zsh
- 10 FTP SFTP Clients and Alternatives - FTP
- Run Gradle Build without test cases - Gradle
- How to Merge Branch into Master Branch - Git
- Java JDK 21: JEP 439 - An Improved Generational Z Garbage Collector (ZGC) - Java-JDK-21
- How to Change Java JDK Version in IntelliJ IDE - Java
- 44: Take a string and print it in lower case. [1000+ Python Programs] - Python-Programs