LinkedList+in+Java
LinkedList+in+Java
Collection
LinkedList
Java Collection Framework:
LinkedList
• LinkedList is a part of collection framework which
implements the List Interface of Collection.
• LinkedList is also dynamic like ArrayList in Java.
• Like ArrayList, LinkedList also can contain the
duplicate elements and also maintain the
insertion order.
Java Collection Framework:
LinkedList
• The only difference in LinkedList and ArrayList is,
LinkedList stores elements in a doubly-linked list data
structure while ArrayList stores elements in a backing
array.
• LinkedList provide constant time for adding and
removing elements at the end of the list
Operations in LinkedList
• void addFirst(Object element) : It inserts the element at
the beginning of the list.
•void addLast(Object element) : It appends the element at
the end of the list.
•void removeFirst(Object element) : It delete the element
at the beginning of the list.
•void removeLast(Object element) : It delete the element
at the end of the list.