LinkedList class Methods in Java Part -I

java.util.LinkedList

Doubly-linked list implementation of the List and Deque interfaces.

Some methods of LinkedList class.


add(K)This method appends the specified element to the end of this list.


add(int, K)This method inserts the specified element at the specified position in this list.


addAll(Collection)This method appends all of the elements in the specified collection to the end of this list.


addAll(int, Collection)This method inserts all of the elements in the specified collection into this list, starting at the specified position.


addFirst(K)This method inserts the specified element at the beginning of this list.


addLast(K e)This method appends the specified element to the end of this list.


clear()This method removes all of the elements from this list.


clone()This method returns a shallow copy of this LinkedList.


contains(Object)This method returns true if this list contains the specified


containsAll(Collection)This method returns true if this collection contains all of the elements in the specified collection.


descendingIterator()This method returns an iterator over the elements in this deque in reverse sequential order


element()This method retrieves but does not remove, the head (first element) of this list.


equals(Object)his method compares the specified object with this list for equality. 


forEach(Consumer)This method performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception.


get(int)This method returns the element at the specified position in this list.


getFirst()This method returns the first element in this list.


getLast()This method returns the last element in this list.


hashCode()This method returns the hash code value for this list.


indexOf(Object)This method returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.


isEmpty()This method returns true if this collection contains no elements.


Some more Methods of LinkedList Part -II


Some more Methods of LinkedList Part -III



No comments:

Post a Comment