Java Singly Linked List Implementation

Here you will get program to implement singly linked list in Java.

Linked list is a linear data structure. It contains different nodes. Each node will store data and reference to the next node. This is the most useful data structure in computer science in construction of trees especially.

Java Singly Linked List Implementation

Output

adding elements to linked list at begining:
4 is added in linked list
list is 4
5 is added in linked list
list is 5 4
7 is added in linked list
list is 7 5 4
10 is added in linked list
list is 10 7 5 4

adding elements to linked list at end:
6 is added at the end of linked list
20 is added at the end of linked list
30 is added at the end of linked list
list is 10 7 5 4 6 20 30

8 is added at the 2nd index of linked list
list is 10 8 7 5 4 6 20 30

deleted the first element
list is 8 7 5 4 6 20 30
deleted the element at pos 2
list is 8 5 4 6 20 30
deleted the element at end
list is 8 5 4 6 20

searching element 5 in list
8 found at pos 1

searching element 15 in list
15 not found

Comment below if you have any queries related to above java singly linked list program.

Leave a Comment

Your email address will not be published. Required fields are marked *