In this article we will discuss how to add elements in LinkedList and then display them.

Lets create a LinkedList of String i.e.

To add elements in LinkedList we will use its add() function i.e.

add() member function of LinkedList always appends the element in the end of LinkedList.

Let’s see how to use the member function to add String elements to LinkedList i.e.

Output:

As we can see the elements in the LinkedList are stored in the order in which they were added. This proves that LinkedList is an ordered collection.

 

In above example we inserted 3 elements at the end of LinkedList.

Python Resources

C++11 / C++14 Resources

Design Patterns Resources

If you didn't find what you were looking, then do suggest us in the comments below. We will be more than happy to add that.

Do Subscribe with us for more Articles / Tutorials like this,