Příklad použití "do-while" cyklu

Dokud není z klávesnice načtena požadovaná hodnota:

String vstup = ""; 
float number; 
boolean isOK; 
// create a reader from standard input
BufferedReader in = new BufferReader(new InputStream(System.in)); 
// until a valid number is given, try to read it
do { 
   String input = in.readLine(); 
   try { 
      number = Float.parseFloat(input); 
      isOK = true;
   } catch (NumberFormatException nfe) { 
      isOK = false; 
   }
} while(!isOK); 
System.out.println("We've got the number " + number);

Příklad: Načítej, dokud není zadáno číslo