

These limitations are handled in the Linked List by providing following features:ġ. Similarly deleting an element from the array is also a performance wise expensive operation because all the elements after the deleted element have to be shifted left. Let’s say we have an array that has following elements: 10, 12, 15, 20, 4, 5, 100, now if we want to insert a new element 99 after the element that has value 12 then we have to shift all the elements after 12 to their right to make space for new element. You must be aware of the arrays which is also a linear data structure but arrays have certain limitations such as:ġ) Size of the array is fixed which is decided when we create an array so it is hard to predict the number of elements in advance, if the declared size fall short then we cannot increase the size of an array and if we declare a large size array and do not need to store that many elements then it is a waste of memory.Ģ) Array elements need contiguous memory locations to store their values.ģ) Inserting an element in an array is performance wise expensive as we have to shift several elements to make a space for the new element. There is another complex type variation of LinkedList which is called doubly linked list, node of a doubly linked list contains three parts: 1) Pointer to the previous node of the linked list 2) content of the element 3) pointer to the next node of the linked list. The diagram which is shown above represents a singly linked list. The Last element of the LinkedList contains null in the pointer part of the node because it is the end of the List so it doesn’t point to anything as shown in the above diagram.ģ. Head of the LinkedList only contains the Address of the First element of the List.Ģ.

Each Node of the LinkedList contains two items: 1) Content of the element 2) Pointer/Address/Reference to the Next Node in the LinkedList.ġ.

Tutorials on LinkedList – All the methods of LinkedList class covered in detail in separate tutorials LinkedList representationĮach element in the LinkedList is called the Node. Java Linked List example of removing elementsĨ. Java Linked List example of adding elementsĥ. Each element of the LinkedList has the reference(address/pointer) to the next element of the LinkedList. However LinkedList elements are not stored in contiguous locations like arrays, they are linked with each other using pointers. Similar to arrays in Java, LinkedList is a linear data structure.
