Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • DSA
  • Data Structures
  • Array
  • String
  • Linked List
  • Stack
  • Queue
  • Tree
  • Binary Tree
  • Binary Search Tree
  • Heap
  • Hashing
  • Graph
  • Trie
  • Segment Tree
  • Disjoint Set Union
  • Fenwick Tree
  • AVL Tree
  • Red-Black Tree
  • Advanced Data Structures
Open In App
Next Article:
Hashing in Data Structure
Next article icon

Inbuild Data Structures in Java

Last Updated : 19 Sep, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

A data structure is a specific way of storing and organizing data so that it can be used effectively and efficiently. An efficient data structure takes up little memory space and requires as little time as possible to execute the data. Java provides a variety of built-in data structures that are commonly used in Data Structures and Algorithms (DSA) implementations.

Here are some of the most important Built-in Data Structures in Java:

Inbuild Data Structure

Internal Working

Static/Dynamic

ArrayList

Array of Object classes

Dynamic

LinkedList

List and Deque

Dynamic

Stack

Vector class

Dynamic

Queue

LinkedList class

Dynamic

PriorityQueue

Binary Heap

Dynamic

HashSet

HashMap

Dynamic

HashMap

Array of buckets

Dynamic

TreeSet

TreeMap 

Dynamic

TreeMap

Red-black tree

Dynamic

HashTable

Slot/Bucket

Dynamic

LinkedHashSet

HashTable and LinkedList

Dynamic


ArrayList:

  • The backing data structure of ArrayList is an array of Object classes. Internally an ArrayList uses an Object[] Array which is an array of objects.
  • All operation like deleting, adding, and updating the elements happens in this Object[] array.

LinkedList:

  • Java's LinkedList class is a versatile and commonly used data structure that implements the List and Deque interfaces while extending the AbstractSequentialList

Stack:

  • The Stack class in Java extends the Vector class, which is a dynamic array-like data structure.
  • Common stack operations are supported, such as push, pop, peek, and isEmpty.

Queue:

  • A queue is a First-In-First-Out (FIFO) data structure used to manage elements in a way that the first element added is the first one to be removed.
  • The Queue interface can be implemented using LinkedList or ArrayDeque.

PriorityQueue:

  • A priority queue stores elements with associated priorities, and elements with higher priorities are dequeued first.
  • The ordering can be based on natural ordering or defined using a comparator.
  • It's typically implemented using a binary heap or another data structure that maintains the priority order.

HashSet:

  • HashSet internally uses HashMap to store it’s elements.
  • Whenever you create a HashSet object, one HashMap object associated with it is also created. 

HashMap:

  • HashMap in Java is basically an array of buckets. where each bucket uses linked list to hold elements.
  • A bucket is a linked list of nodes where each node is an object of class Node<K,V>.

TreeSet:

  • The TreeSet internally uses the TreeMap to store the elements.
  • Whenever we create a TreeSet, The JVM internally creates a TreeMap and perform all the operations on TreeMap.

TreeMap:

  • TreeMap is a red-black tree-based implementation of the Map interface, NavigableMap, and AbstractMap classes.

HashTable:

  • Hash table intrinsically contains a slot/bucket in which the storage of key and value pair.
  • It uses the key’s hash code to discover which bucket the key/value of a set should map.

LinkedHashSet:

  • LinkedHashMap in Java is an implementation that combines HashTable and LinkedList implementation.
  • It implements the Map interface.



Next Article
Hashing in Data Structure

M

mridul_gfg
Improve
Article Tags :
  • Data Structures
  • DSA
Practice Tags :
  • Data Structures

Similar Reads

  • Hashing in Data Structure
    Hashing is a technique used in data structures that efficiently stores and retrieves data in a way that allows for quick access. Hashing involves mapping data to a specific index in a hash table (an array of items) using a hash function. It enables fast retrieval of information based on its key. The
    3 min read
  • LMNs-Data Structures
    Data structures are ways to organize and store data so it can be used efficiently. They are essential in computer science for managing and processing information in programs. Common types of data structures include arrays, linked lists, stacks, queues, trees, and graphs. Each structure is designed f
    15 min read
  • Linked List Data Structure
    A linked list is a fundamental data structure in computer science. It mainly allows efficient insertion and deletion operations compared to arrays. Like arrays, it is also used to implement other data structures like stack, queue and deque. Here’s the comparison of Linked List vs Arrays Linked List:
    3 min read
  • Introduction to Data Structures
    What is Data Structure?A data structure is a particular way of organising data in a computer so that it can be used effectively. The idea is to reduce the space and time complexities of different tasks. The choice of a good data structure makes it possible to perform a variety of critical operations
    7 min read
  • Advanced Data Structures
    Advanced Data Structures refer to complex and specialized arrangements of data that enable efficient storage, retrieval, and manipulation of information in computer science and programming. These structures go beyond basic data types like arrays and lists, offering sophisticated ways to organize and
    3 min read
  • Introduction to Linear Data Structures
    Linear Data Structures are a type of data structure in computer science where data elements are arranged sequentially or linearly. Each element has a previous and next adjacent, except for the first and last elements. Characteristics of Linear Data Structure:Sequential Organization: In linear data s
    8 min read
  • Heap Data Structure
    A Heap is a complete binary tree data structure that satisfies the heap property: for every node, the value of its children is greater than or equal to its own value. Heaps are usually used to implement priority queues, where the smallest (or largest) element is always at the root of the tree. Basic
    2 min read
  • Stack Data Structure
    A Stack is a linear data structure that follows a particular order in which the operations are performed. The order may be LIFO(Last In First Out) or FILO(First In Last Out). LIFO implies that the element that is inserted last, comes out first and FILO implies that the element that is inserted first
    3 min read
  • Queue Data Structure
    A Queue Data Structure is a fundamental concept in computer science used for storing and managing data in a specific order. It follows the principle of "First in, First out" (FIFO), where the first element added to the queue is the first one to be removed. It is used as a buffer in computer systems
    2 min read
  • Array Data Structure Guide
    In this article, we introduce array, implementation in different popular languages, its basic operations and commonly seen problems / interview questions. An array stores items (in case of C/C++ and Java Primitive Arrays) or their references (in case of Python, JS, Java Non-Primitive) at contiguous
    4 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences