Chapter 3 Flashcards
the if(condition) must be
a boolean, true or false
If the condition is true
the statement is executed, if not skipped
==
equals
!=
does not equal
<=
less than or equal to
> =
greater than or equal to
else is similar to
otherwise
Without braces
only one statement can follow the if statement
a && b
if both a and b are true, executes
a || b
If either a or b are true, executes
!a
executes if a is false
&& and || are
binary operators
order of logical precedence
NOT over AND and OR
De Morgan’s theorem
When the not (!) is distributed to the variable in the parentheses
short circuiting
when the left operand of an “&&” statement or “||” is true, other part is not evaluated
How to compare strings
“equals method” and
“compareTo”
lexicographic ordering
Compares characters and Strings based on a character set
alphabetical order, and short strings with same prefix as long go first
“book” before “bookcase”
increment operator ++
adds one to its operand
decrement operator –
subtracts one from its operand
num += count is equal to
num = num + count;
num -= count is equal to
num = num- count
num *= count is equal to
x = x*y
num /= count is equal to
x = x/y
num %= count is equal to
x = x%y