Show Menu
Cheatography

Java Interview WY Cheat Sheet (DRAFT) by

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

Collec­tions - meta

Queues
ArrayB­loc­kin­gQueue, Concur­ren­tLi­nke­dQueue, DelayQ­ueue, Linked­Blo­cki­ngD­eque, Linked­Blo­cki­ngQ­ueue, Linked­Tra­nsf­erQ­ueue, Priori­tyB­loc­kin­gQueue, Priori­tyQ­ueue, Synchr­ono­usQueue
Lists
ArrayList, Linked­List, CopyOn­Wri­teA­rra­yList
Sets
TreeSet, HashSet, Linked­Has­hSet, EnumSet, Concur­ren­tSk­ipL­istSet
Map
HashMap, Concur­ren­tHa­shMap, SortedMap, TreeMap, WeakHa­shMap, EnumMap, Identi­tyH­ashMap
At a high level, collec­tions roughly fall into Lists, Queues, Maps or Sets

We also have to distin­guish between concurrent collec­tions and non-co­ncu­rrent collec­tions

java.u­til.co­ncu­rrent - meta

Executor
Thread­Poo­lEx­ecutor, Schedu­led­Thr­ead­Poo­lEx­ecutor, Execut­orC­omp­let­ion­Service
Queue
Linked­Blo­cki­ngQ­ueue, ArrayB­loc­kin­gQueue, Synchr­ono­usQ­ueue, Priori­tyB­loc­kin­gQueue, DelayQueue
Synchr­onizers
Countd­own­Latch, Cyclic­Bar­rier, Semaphore, Phaser, Exchanger
Map
Concur­ren­tHa­shMap, Concur­ren­tSk­ipL­istSet
java.u­til.co­ncu­rrent has some special items in there. I skip all the ones that come to mind (e.g. executors) and put in some that are somewhat fuzzy

Most common sychro­nizers methods

Countd­own­Latch
countdown, await(­tim­eoutMs, TimeUnit)
Can only be used once. No RESET. Thread does not block on countdown, only on await
Cyclic­Barrier
Cyclic­Bar­rie­r(c­ount), reset(), await(­tim­eoutMs, TimeUnit)
Can be used multiple times