What is LinkedList and an example in Java?
LinkedList is a linear collections of data elements.
// Declaring LinkedList
LinkedList<String> abclinked = new LinkedList<String>();
abclinked.add(“a”);
abclinked.add(“b”);
abclinked.add(“c”);
system.out.println(“the linked list is ” + abclinked )
Linked Lists are Dynamic size and this feature certainly has an endge over Array. insertion and deletion also possible for Linked Lists which may not be done on Array which is already defined.
The downside of Linked Lists is that the extra memory space for a pointer is required with each element of the list. Also accessing elements are sequential manner starting from the first node is difficult.