...

/

LinkedList: Introduction

LinkedList: Introduction

Let's see how LinkedList works in Java.

The LinkedList class in Java implements the List and the Deque interface. Some of the salient features of a LinkedList are:

  1. The elements are inserted in the order of insertion.

  2. It supports duplicate elements.

  3. We can add any number of null elements.

Internal implementation of LinkedList

The LinkedList class has a static inner class called Node. This class contains three fields:

item - This contains the value of the current element.

next - This contains the pointer to the next element.

prev - This contains the pointer to the previous element.

Below is the code for the Node class.

 ...