GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • About
  • Reference
  • Integrations
  • API
  • Blog
  • Java Syntax Reference
  • Feedback

This view

  • Original page
  • New address

GeezerVison is showing syntaxdb.com — Do-While Loop in Java - SyntaxDB - Java Syntax Reference

    Java
  • C
  • C++
  • C#
  • Python
  • Ruby
  • JavaScript
  • Swift
  • Go
Languages
    • User Program Communication
      • Print
      • User Input
      • Commenting
      • Read from Text File
      • Write to File
      • Import Package
    • Variables
      • Primitive Data Types
      • Type Casting
      • Variable Declaration
      • Constants
      • Arrays
      • HashMaps
      • HashSets
    • Control Flow
      • If Statement
      • Switch Case
      • Ternary Operator
      • For Loop
      • For Each
      • While Loop
      • Do-While Loop
      • Try Catch Block
    • Object Oriented Programming
      • Class Declaration
      • Access Modifiers
      • Constructor
      • Instantiation
      • Class Variables
      • Standard Methods
      • Class Methods
      • Inheritance
      • Interfaces
      • Abstract Methods and Classes
      • Anonymous Class
      • Declaring an Exception
      • Throwing an Exception
    • String Class
      • String Variables
      • String Length
      • String Compare
      • String Trim
      • Split String
      • Substring
      • String Representation
Categories
Language
Java
  • Java
  • C
  • C++
  • C#
  • Python
  • Ruby
  • JavaScript
  • Swift
  • Go
Version: SE 8

Categories

  • User Program Communication
    • Print
    • User Input
    • Commenting
    • Read from Text File
    • Write to File
    • Import Package
  • Variables
    • Primitive Data Types
    • Type Casting
    • Variable Declaration
    • Constants
    • Arrays
    • HashMaps
    • HashSets
  • Control Flow
    • If Statement
    • Switch Case
    • Ternary Operator
    • For Loop
    • For Each
    • While Loop
    • Do-While Loop
    • Try Catch Block
  • Object Oriented Programming
    • Class Declaration
    • Access Modifiers
    • Constructor
    • Instantiation
    • Class Variables
    • Standard Methods
    • Class Methods
    • Inheritance
    • Interfaces
    • Abstract Methods and Classes
    • Anonymous Class
    • Declaring an Exception
    • Throwing an Exception
  • String Class
    • String Variables
    • String Length
    • String Compare
    • String Trim
    • Split String
    • Substring
    • String Representation

Control Flow

Do-While Loop in Java

The do-while loop executes a block of code while a boolean expression evaluates to true. It checks the boolean expression after each iteration. It terminates as soon as the expression evaluates to false.


Syntax
do { 
    //block of code to be executed
} while(booleanExpression);

Notes

Because the do-while loop evaluates the boolean expression at the end of the iteration, the block of code within the loop is guaranteed to run at least once.

booleanExpression results in either a true or false output. It is created using comparing operators (==, >, =, <=, !=).

There can also be multiple boolean expressions within the parentheses (booleanExpression). The boolean expressions are connected through logical operators (&&, ||, !).


Example
int x = 0; 
do { 
    System.out.println(x); 
    x++; 
} while(x < 10);

Add to Slack

< While Loop   |   Class Declaration >


You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.