List Traversal


There are so many questions comes into mind when we go to the coding floor and starts writing the code for list like how to traverse the list in java? What are the different ways to traverse a list? Which is the best way? Which way needs to be followed?

Here, we will try to find out the answers of these questions.

There are two ways to traverse the list - forward or backward. The list has given methods like next and previous.

We can iterate the list starting from a specific index too.



Output :
Iterating list in forward direction...
one
two
three
four
five
Iterating list in backward direction...
five
four
three
two
one
Iterating list from specified position...
three
four
five

Look at my other posts:

Some other interesting blogs:

Comments

Popular posts from this blog

Custom Stack Implementation in java

List - Insertion order

Custom LinkedList Implementation