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
can add up
assignment operators
repetition statements
while and for loops
If a while loop does not eventually make the condition false
it is an infinite loop
for loops execute a specific number of times
yes
how to establish for loop
for(initialize; condition; increment)
algorithm
step by step process for solving a problem
psuedo code
helps to solve algorithm, mix of English and code
top-down development
starts at top, priority code, and goes down
regression testing
running programs over and over to find problem
flow of control
program runs from one line to the next until program is complete