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.

Join LinkedIn Group of Python Professional Developers who wish to expand their network and share ideas.

You can also follow us On Twitter :

Click Here to Subscribe for more Articles / Tutorials like this.