Member-only story
Linked List fundamentals: Concept and Java Implementation
3 min readNov 25, 2023
Table of contents:
· What is Linked List?
· Implementation of a Linked List in Java
∘ Traverse and print a linked list
∘ Search
∘ Insertion
∘ Deletion
What is Linked List?
Linked list is a type of data structure in which each node contains the data of the node and at least one pointer pointing to the next node in the list. Unlike array, nodes in a linked list are not stored in contiguous memory locations. For this reason, we need to store information of the head of a linked list so that we know where to access it.
Implementation of a Linked List in Java
class Node {
int data;
Node next;
Node(int data) {
this.data = data;
next = null;
}
}
class Main(Strings[] args){
Node head = new Node(10);
Node temp1 = new Node(20);
Node temp2 = new Node(30);
head.next = temp1;
temp1.next = temp2;
}