LinkedList (Java SE 25 & JDK 25)
- Type Parameters:
E- the type of elements held in this collection
- All Implemented Interfaces:
Serializable, Cloneable, Iterable<E>, Collection<E>, Deque<E>, List<E>, Queue<E>, SequencedCollection<E>
-
Field Summary
-
Constructor Summary
Constructors
Constructs an empty list.
Constructs a list containing the elements of the specified collection, in the order they are returned by the collection's iterator.
-
Method Summary
voidInserts the specified element at the specified position in this list.
booleanAppends the specified element to the end of this list.
booleanInserts all of the elements in the specified collection into this list, starting at the specified position.
booleanAppends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator.
voidInserts the specified element at the beginning of this list.
voidAppends the specified element to the end of this list.
voidclear()Removes all of the elements from this list.
clone()Returns a shallow copy of this
LinkedList.booleanReturns
trueif this list contains the specified element.Returns an iterator over the elements in this deque in reverse sequential order.
element()Retrieves, but does not remove, the head (first element) of this list.
get(int index) Returns the element at the specified position in this list.
getFirst()Returns the first element in this list.
getLast()Returns the last element in this list.
intReturns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.
intReturns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.
listIterator(int index) Returns a list-iterator of the elements in this list (in proper sequence), starting at the specified position in the list.
booleanAdds the specified element as the tail (last element) of this list.
booleanofferFirst(E e) Inserts the specified element at the front of this list.
booleanInserts the specified element at the end of this list.
peek()Retrieves, but does not remove, the head (first element) of this list.
Retrieves, but does not remove, the first element of this list, or returns
nullif this list is empty.peekLast()Retrieves, but does not remove, the last element of this list, or returns
nullif this list is empty.poll()Retrieves and removes the head (first element) of this list.
Retrieves and removes the first element of this list, or returns
nullif this list is empty.pollLast()Retrieves and removes the last element of this list, or returns
nullif this list is empty.pop()Pops an element from the stack represented by this list.
voidPushes an element onto the stack represented by this list.
remove()Retrieves and removes the head (first element) of this list.
remove(int index) Removes the element at the specified position in this list.
booleanRemoves the first occurrence of the specified element from this list, if it is present.
Removes and returns the first element from this list.
booleanRemoves the first occurrence of the specified element in this list (when traversing the list from head to tail).
Removes and returns the last element from this list.
booleanRemoves the last occurrence of the specified element in this list (when traversing the list from head to tail).
reversed()Returns a reverse-ordered view of this collection.
Replaces the element at the specified position in this list with the specified element.
intsize()Returns the number of elements in this list.
toArray()Returns an array containing all of the elements in this list in proper sequence (from first to last element).
<T> T[]toArray(T[] a) Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array.
Methods declared in interface List
containsAll, equals, hashCode, isEmpty, iterator, listIterator, removeAll, replaceAll, retainAll, sort, subList
-
Constructor Details
-
LinkedList
-
LinkedList
-
-
Method Details
-
getFirst
-
getLast
-
removeFirst
-
removeLast
-
addFirst
-
addLast
-
contains
-
size
-
add
-
remove
-
addAll
-
addAll
-
clear
-
get
-
set
-
add
-
remove
-
indexOf
-
lastIndexOf
-
peek
-
element
-
poll
-
remove
-
offer
-
offerFirst
-
offerLast
-
peekFirst
-
peekLast
-
pollFirst
-
pollLast
-
push
-
pop
-
removeFirstOccurrence
-
removeLastOccurrence
-
listIterator
-
descendingIterator
-
clone
-
toArray
-
toArray
-
spliterator
-
reversed
-