Java: List of Data Structures available


Below is the list of Standard Data Structures provided in the Java Programming Langauge.

  1. 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.

    Array Data Structure in Java
    • 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
  2. ArrayList:

    ArrayList Data Structure is a dynamic array in Java that can grow or shrink during runtime.

    ArrayLists Data Structure in Java
    • 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
  3. 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.

    LinkedList Data Structure in Java
    • 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
  4. 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.

    Stack Data Structure in Java
    • 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
  5. 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.

    Queue Data Structure in Java
    • 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
  6. 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
  7. Set:

    Set data structure is a collection of unique elements that does not allow duplicate values.

    Set Data Structure Java
    • 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
  8. 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
  9. 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.

    TreeSet Data Structure in Java
    • 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
Author Info:

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










Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap