University of Cincinnati logo and link  
Data Structures
 

 

Linked Lists in Java

  Java provides a class, java.util.LinkedList, for linked lists. This class extends the List interface, among other interfaces.  This class provides uniformly named elements to get, insert, and remove an element at the beginning and end of a list. These operations allow LinkedList to be used as a stack, queue, or double-ended queue. 

Some of the methods include:
Object get(int index)
Object getFirst()
Object getLast()

Object remove(int index)
boolean remove(Object o)
Object removeFirst()
Object removeLast()

void add(int index, Object element) - adds an element at the specified position and shifts others over.
void addFirst(Object o)
void addLast(Object o)

Object set(int index, Object element) - replaces the element at the specified position and returns it.

List Iterator