Creating a custom linked list in Java

 

Creating a custom linked list in Java
Creating a custom linked list in Java


The linked list data structure stores object in the non-contigeous memory location.  To achieve this feature it is to create a node for each object. And a single node contains two parts. The first part is the data part, which could be of any type and the second part is the pointer which basically contains the next node's memory address. This could be a singly or a doubly linked list.

When we create a node of a singly linked list for the first time, the head part is null because there is only one node in the list.

When we add the next node to the list we append the next node to the first node and the process goes on as long as we insert data or objects into the list.

And we print or fetch the objects from the list, we first check if the head is null then there is no object in it. Otherwise, we fetch the object from the list.




Post a Comment

0 Comments