Since there are no self-refering pointer concept in Java… How do I proceed to tackle this issue…
I am not allowed to use Built in class of Link List in Java…
But “Should follow the same method of creation of Link List like in C.” What could be the best Substitute node->next, node->prev in Java…
Instead of an object with a pointer to the next node and an var, in java linked lists can be implemented by making a class with a member variable of itself.
a sample implementation is listed below:
To create a link list, create head:
This node class has two ways of adding nodes to the list:
or
here is an example of a list with values 1 – 10
now you can print access the elements of this list by iterating through the list.