Show Menu
Cheatography

Java Collections Cheat Sheet (DRAFT) by

Java Collections

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

List

add(el)
lastIn­dexOf()
add(idx, el)
listIt­era­tor()
addAll­(Co­lle­ction c)
listIt­era­tor­(idx)
clear()
remove­(idx)
contai­ns(el)
remove(el)
contai­nsA­ll(­Col­lection c)
replac­eAl­l(U­nar­yOp­erator op)
equals­(List l)
retain­All­(Co­lle­ction c)
get(idx)
set(idx, el)
hashCode()
size()
indexO­f(el)
sort(C­omp­arator c)
isEmpty()
subLis­t(from, to)
iterator()
toArray()
 

Linked List

addFir­st(el)
peekFi­rst()
addLas­t(el)
peekLast()
clone()
poll()
getFirst()
pollFi­rst()
getLast()
pollLast()
offer(el)
pop()
offerF­irs­t(el)
push(el)
offerL­ast(el)
remove­First()
peek()
remove­Last()

Map

clear()
keySet()
contai­nsK­ey(key)
put(key, val)
contai­nsV­alu­e(v­alue)
putAll(Map m)
entrySet()
putIfA­bse­nt(key, val)
equals(Map m)
remove­(key)
get(key)
remove­(key, val)
getOrD­efa­ult­(key, defaul­tValue)
replac­e(key, val)
hashCode()
size()
isEmpty()
values()
 

Set

add(el)
iterator()
addAll­(Co­lle­ction c)
remove(el)
clear()
remove­All­(Co­lle­ction c)
contai­ns(el)
retain­All­(Co­lle­ction c)
equals(Set s)
size()
hashCode()
toArray()
isEmpty()

Queue

add(el)
iterator()
addAll­(Co­lle­ction c)
offer(el)
clear()
peek()
contai­ns(el)
poll()
contai­nsA­ll(­Col­lection c)
remove()
element()
remove­All()
equals­(Queue Q)
retain­All()
hashCode()
size()
isEmpty()
toArray()