Table of Contents [hide]
In this post, we will see how to implement singly linked list in java.
It is one of the most used data structure. In singly linked list, Node has data and pointer to next node. It does not have pointer to the previous node. Last node ‘s next points to null, so you can iterate over linked list by using this condition.
Node for linked list can be presented as below:
Lets create Main class named LinkedListMain.java to create LinkedList.
When you run above program, you will get below output:
It is one of the most used data structure. In singly linked list, Node has data and pointer to next node. It does not have pointer to the previous node. Last node ‘s next points to null, so you can iterate over linked list by using this condition.
Node for linked list can be presented as below:
An example of linked list:

Let’s implement Linked List in java.
Create a java file named SinglyLinkedList.java.
Was this post helpful?
Let us know if this post was helpful. Feedbacks are monitored on daily basis. Please do provide feedback as that\'s the only way to improve.
Nice Sir Arpit ~! 🙂
Beautifully written sir. Thank you 🙂
Hi
good job.
Your comment before insertLast(int data) method is wrong.
This was the best implementation of Linked List in java I’ve seen on the internet. Thank you so much, cleared all my concepts.
This was the way I was looking up for.
Thank you so much.