Using do Loops : do while « Statements « SCJP






The expression is not evaluated until after the do loop's code is executed. 
Therefore the code in a do loop is guaranteed to execute at least once. 

do{
   repeated_statement_or_block
}while (boolean_condition);




do-while loop always executes the body at least once

public class MainClass {
  public static void main(String[] argv) {
    do {
      System.out.println("here");
    } while (false);

  }
}

class MainClass{
 public static void main(String[] args) {
  boolean finished = false;
  do {
   double d = Math.random();
   if(d > .5) finished = true;
   System.out.println(d);
  } while (!finished);
 }
}
0.7301791528096938








5.2.do while
5.2.1.Using do Loops