Linked-list
In this article, we will quickly look into what is linked list?, comparison with Arrays, advantage and disadvantages over Arrays and types of linked lists.
What is a Linked List?
A linked list is a data structure used for storing collections of data. A linked list has the following properties.
Each link is linked with its next link using its next link.
The last link carries a link as null to mark the end of the list.
Difference Between Linked lists and Arrays
As we know that both linked lists and Arrays are used to store collections of data, and since both are used for the same purpose, we need to differentiate their usage. That means in which cases arrays are suitable and in which cases linked lists are suitable.
Let's first briefly look at advantage and disadvantage of Arrays then we will compare Arrays with Linked lists.
Array Overview
An array is a container object that holds a fixed number of values of a single type.
The length of an array is established when the array is created. After creation, its length is fixed.
As we know Array is a data structure where we store similar elements and Array starts from index 0.
Each item in an array is called an element, and each element is accessed by its numerical index.
Since arrays are objects in Java, we can find their length using member length.
A Java array variable can also be declared like other variables with [] after the data type.
The variables in the array are ordered and each has an index beginning from 0.
Java array can be also be used as a static field, a local variable or a method parameter.