Java Reference
In-Depth Information
public
LinkedList()
Creates a new empty
LinkedList
.
public
LinkedList(Collection<? extends E> coll)
Creates a new
LinkedList
whose initial contents are those of
coll
. The order is that returned by the collection's iterator.
public E
getFirst()
Returns the first object in this list.
public E
getLast()
Returns the last object in this list.
public E
removeFirst()
Removes the first object in this list.
public E
removeLast()
Removes the last object in this list.
public void
addFirst(E elem)
Adds
elem
into this list as the first element.
public void
addLast(E elem)
Adds
elem
into this list as the last element.
A
LinkedList
is a good base for a queueand indeed it implements the
Queue
interface discussed nextor any other list in which most of the ac-
tion is not at the end. For a stack, or for building up a list of elements as