Show Menu
Cheatography

Good code practice Cheat Sheet (DRAFT) by

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

Examples

The parameter weekday is true if it is a weekday, and the parameter vacation is true if we are on vacation. We sleep in if it is not a weekday or we're on vacation. Return true if we sleep in.
sleepIn(false, false) → true
sleepIn(true, false) → false
sleepIn(false, true) → true
public boolean sleepI­n(b­oolean weekday, boolean vacation) {
if (!weekday || vacation) {
return true;
}
return false;
}

 

( )

(a == true)
(a)
(a == false)
(!a)

return

if( Math.a­bs((100 - n)) <= 10 || Math.a­bs((200 - n)) <= 10 ){ return true; } return false;
return ((Math.ab­s(100 - n) <= 10) || (Math.a­bs(200 - n) <= 10));
You can type statements that are either true or false into a return