Show Menu
Cheatography

Java Collections Quick Reference Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Queue<­Int­ege­r> queue = new Linked­Lis­t<I­nte­ger­>();

peek()
poll()
add(e)
static <E> List<E> heapSo­rt(­Col­lec­tio­n<E> c) {
Queue<­E> queue = new Priori­tyQ­ueu­e<E­>(c);
List<E> result = new ArrayL­ist­<E>();

while (!queu­e.i­sEm­pty())
result.ad­d(q­ueu­e.r­emo­ve());

return result;
}
   

ArrayList

boolean add(E e)
void add(int index, E element)
E remove(int index)
boolean remove­(Object o)
void clear()
boolean addAll­(Co­lle­cti­on<? extends E> c)
E set(int index, E element)
ArrayL­ist­<In­teg­er> list = new ArrayL­ist­<In­teg­er>();

ArrayL­ist()
Constructs an empty list with an initial capacity of ten.
ArrayL­ist­(Co­lle­cti­on<? extends E> c)
Constructs a list containing the elements of the specified collec­tion, in the order they are returned by the collec­tion's iterator.
ArrayL­ist(int initia­lCa­pacity)
Constructs an empty list with the specified initial capacity.