Control flow statements

Java - 10 Cards
Click here to toggle all cards
Control Flow Statement
Statements that control how a program runs
If-Else Statement
A statement that runs different code depending on a condition
If-Else Syntax
if (condition){ //code -> if condition is true } else { //code -> if condition is false }
Switch Statement
A statement that lets you choose between multiple cases of code
Switch Syntax
switch(expression) { case value1: // code break; default: // code }
Scanner
A Java class for getting user input from the console
default clause
Code that runs if no switch cases match
break statement
A statement that exits out of a loop or switch statement
Ternary Operator
A shorthand if statement that assigns a value based on a condition
Ternary Operator Syntax
result = (condition ? expression-if-condition-true : expression:if-condition-false);