CoderSathi
  • Tutorial
    • Java Tutorial
    • Swing Tutorial
    • JDBC Tutorial
    • Java String Tutorial
    • Servlet and JSP Tutorial
  • Mongo DB
  • AWS
  • DevOps
  • Linux
  • Git
Home > Java > LinkedList in Java

Java Tutorial

  • Introduction
    • What is Java
    • History Of Java
    • Install Java
    • What is JVM
    • JDK vs JRE vs JVM
    • Java Bytecode
    • OOP vs POP
    • Compile and Run Java
  • Tokens, Expressions and Control Structures
    • Primitive data types
    • Integers
    • Floating Points
    • Characters
    • Booleans
    • User Defined Data Type
    • Declarations
    • Constants
    • Identifiers
    • Literals
    • Type Conversion and Casting
    • Variables
    • Default Variable Initialization
    • Command Line Arguments
    • Arrays of Primitive Types
    • Comment Syntax
    • Garbage Collection
    • Expressions
    • Operators
    • Arithmetic Operator
    • Bitwise and Shift Operator
    • Comparison or Relational Operators
    • Logical Operators
    • Assignment Operators
    • Ternary Operator
    • Increment and Decrement Operator
    • Control Statements
  • OOP Concepts
    • Class and Object
    • Create Class Instance
    • Method
    • Abstraction
    • Encapsulation
    • this keyword
    • Constructor
    • Pass by Value
    • Access Modifier/Control
    • Polymorphism
    • Method Overloading vs Method Overriding
    • Recursion
    • Nested and Inner Class
  • Inheritance and Packaging
    • Inheritance
    • extends Keyword
    • super Keyword
    • Object Class
    • Abstract class
    • Final Class
    • Java Package
    • Interface
  • Handling Error/ Exceptions
    • What is Exception
    • Exception Handling Keywords
    • Common Java Errors
    • User Defined Exception
    • Throwing and re-throwing Exception
    • finally Block
  • Strings
    • Java String Tutorial
  • Threads
    • Introduction
    • Create Thread
    • Thread Lifecycle
    • Thread Priority
    • Thread Synchronization
    • Inner Thread Communication
    • Thread Deadlock
  • IO and Streams
    • java.io Package
    • Files and Directories
    • Byte Stream
    • Character Stream
    • Console Input and Output
    • Serializable and Deserializable
  • Core Packages
    • java.lang Package
    • Math
    • Wrapper Classes
    • java.lang.Number
    • Double
    • Float
    • Integers
    • java.lang.Byte
    • java.lang.Short
    • java.lang.Long
    • java.lang.Character
    • java.lang.Boolean
    • java.util package
    • Vector Class
    • Stack Class
    • Dictionary Class
    • Hashtable
    • Enumeration or Enum
    • Generate Random Number
  • Holding Collection of Data
    • Arrays
    • Map
    • List
    • Set
    • Collection Interface
    • Collections Class
    • ArrayList
    • HashSet
    • TreeSet
    • Comparator
  • Java Bean
    • What is Java Bean
    • Advantages and Disadvantages of Java Bean
    • Java Beans API
    • Introspection
    • Java Bean Properties
    • Bound and Constrained Properties
    • BeanInfo Interface
    • Customizers
    • Java Beans Persistence
    • BeanDescriptor

LinkedList in Java

Learn the concepts, implementation details, and practical steps with a clean developer-focused walkthrough.

Yuba Raj Kalathoki
By Yuba Raj Kalathoki
Last updated: July 1, 2026 · 3 min read · 0 Comments
Share: in X

LinkedList is a widely used data structure in the Java programming language. It is a part of the Java Collection Framework and is an implementation of the List interface. It is implemented using a doubly-linked list, which allows for fast and efficient data retrieval, insertion, and deletion. In this blog post, we will discuss what LinkedList is. How it works. And how to use it in Java, including examples of all the available methods.

What is LinkedList in Java?

A LinkedList is an ordered collection of elements that allows for duplicate values. It is implemented using a doubly-linked list, which means that each element is linked to the previous and next elements. This allows for fast and efficient data retrieval, insertion, and deletion, especially at the beginning or end of the list.

Why use LinkedList in Java?

LinkedList is useful in situations where we need to work with a collection of objects and need to maintain the order of the elements. It is particularly useful when we need to perform operations such as adding and removing elements at the beginning or end of the List.

LinkedList also provides a linked list implementation for stack and queue operations which allows for fast insertions and deletions at the beginning and end of the list.

How to use LinkedList in Java?

Using LinkedList in Java is relatively simple. To create a LinkedList, we first need to import the java.util package, which contains the LinkedList class.

Following is an example of creating a LinkedList and adding data to it:

import java.util.LinkedList;

LinkedList<Integer> list = new LinkedList<Integer>();
list.add(1);
list.add(2);
list.add(3);

The output of the above example is given below:

[1, 2, 3]

Once we have created the LinkedList, we can add data to it using the add() method. In the example above, we are adding three elements to the LinkedList.

We can also retrieve data from a LinkedList using the get() method. For example, to retrieve the second element in the LinkedList, we can use the following code:

The output of the above example code is:

2

LinkedList also provides several other useful methods such as addFirst(), addLast(), removeFirst(), removeLast(), and size() to manipulate the elements in the list. These methods’ use case is described in the table below:

MethodDescription
void addFirst(E element);Inserts the specified element at the beginning of this list.
void addLast(E element);Appends the specified element to the end of this list.
E removeFirst();Removes and returns the first element from this list.
E removeLast();Removes and returns the last element from this list.
int size();Returns the number of elements in this list.

Further reading:

  • Create LinkedList in Java
  • Singly vs Doubly LinkedList in Java

Reference: LinkedList

Related Posts:

  • List in Java
  • Control Statements in Java
  • Arrays in Java
  • What Is Java Swing? A Complete Guide to Java’s GUI Toolkit
  • MySQL Commands for Developers
  • What is Java? Exploring Its Key Features, Benefits,…
Tags:collection-frameworkjava
Was this article helpful?
← Previous ArticleShort Circuit Logical Operator in Java
Next Article →JLabel in Java Swing

Recent Posts

  • How to implement Passwordless Authentication in Spring Boot: A Step-by-Step Guide
  • How to Use AWS CloudFront Signed URLs in Spring Boot?
  • How to Fix SSH Agent Forwarding on macOS: The Ultimate Guide for Developers
  • How to Read AWS Secrets Manager in Spring Boot (Step-by-Step)
  • How to Fix “Public Key Retrieval is not allowed” MySQL JDBC Error
CoderSathi

Your go-to resource for Java, Spring Boot, Microservices, AWS, and modern development tutorials.

Linkedin

Quick Links

  • About
  • Contact

Popular Topics

  • Java
  • Spring Boot
  • AWS
  • DevOps
  • MongoDB
  • Linux
  • Git
  • How to
© 2026 CoderSathi. All rights reserved. Privacy Policy · Sitemap