Thomas Mullaly

DevOps, Security and IT Leadership

Java Review - Flow Control

Selection

##If statements with optional else clauses

if (boolean condition)
  statement;
else
statement;

Switch statements

switch (interger value) {
  case FIRST_NAME:
    statements;
  case SECOND_NAME:
    statements;
  default:
    statements;
}

#Repetition

While

while (scan.hasNext()) {
  statements; // repeated until false above
}

For

for (int i = 0; i < MAX; i++) {
  statements; // repeated until false above
}

Do … while

do {
  statements; // repeated until false above
} while (done!);