Top
Previous Next
Java Arrays, Objects, Methods CS 161 - Java

Control Flow - Loops

"for" loops

Perform group of statements for a number of times
  for (initialization ; expression that evaluates to boolean ; increment) {

    // Code that executes each time through the loop ...

  }

"while" loops

Perform group of statements while a condition is statisfied
  while (expression that evaluates to boolean  ) {

    // Code that executes each time through the loop ...

  }

"do ... while" loops

Perform group of statements while a condition is statisfied
  do {

    // Code that executes each time through the loop ...

  } while (expression that evaluates to boolean  );

Question: How is while different from do ... while


Top
Previous Next
jwd