Member-only story

Linked List fundamentals: Concept and Java Implementation

Code Canvas
3 min readNov 25, 2023

--

Photo by Edrin Spahiu on Unsplash

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

Singly Linked List
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;
}

Traverse and print a linked list

--

--

Code Canvas
Code Canvas

Written by Code Canvas

Hi, I'm Hi Tran, a tech and personal growth enthusiast . I use this Medium to document my journey and share insights that may help you on your own path.

No responses yet