Statements Flashcards
Control Flow Statements
control the execution of other statements with logic
Expression Statements
statements built from expressions joined by operators
Expressions
- returns a value
- Method invocations and equations using operators are expressions
Statements
- Similar to a sentence in natural language
- Built from one or more expressions
- Uses of assignment operator, method invocations and the new keyword are all statements
Block
a series statements between curly brackets {}
Control Flow Statements: Decision
use boolean logic to execute one statement instead of another (if the condition has been met or not)
Control Flow Statements: Loop
repeat a statement so long as boolean expression returns true
Switch statements
-Evaluates a single expression to take an action based on the value (could have multiple execution paths based on that value)
While loop
- runs as long as boolean expression is true
- expression should eventually return false
Do-while
like a while loop but the statement