











Singly Linked List in Java


What do you mean by singly linked list in Java programming?
Singly linked list in Java is one of the simplest data structure and used for the implementation of advance data structures such as tree and graph. Singly linked list are efficient as compared to arrays because every node of the list have a pointer that points to the address of next node in the list thus most of the operations in the list becomes easy.
Let us see more about singly linked list in Java programming in this article.
Advantages of Singly Linked List
.
- Dynamic Data Structure
Linked list is a dynamic in nature so it can grow and shrink at runtime by allocating and deallocating memory.
- Insertion and Deletion
Insertion and Deletion becomes easy in linked list .
- Memory Wastage
As linked list is dynamic in nature we can increase as well as decrease the size of list thus memory is saved
- Implement
Linked list are widely used in programming of stacks and queues .
Structure of singly linked list in Java
class Node {
int data;
Node next;
Node(int d)
{
data = d;
next=null;
}
}
Operation on singly linked list
- Deletion
- Insertion
- Traversals
Java code for creating a singly linked list
OUTPUT:
300
400
500
Login/Signup to comment