1 / 4

While Loop in Java - Quipoin

While loop is a pre-test loop which means the condition will be first checked then the statement will execute. The while loop repeats the statement till the condition is true.When the condition is false then execution comes out from the loop.<br>for more free learning visit:<br>https://quipoin.com/view/Java/While

quipoin
Download Presentation

While Loop in Java - Quipoin

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. While Loop while loop in Java

  2. Overview • While loop is a pre-test loop which means the condition will be first checked then the statement will execute.  • The while loop repeats the statement till the condition is true. •  When the condition is false then execution comes out from the loop. •  In the while loop,  based on the condition block statement is executed.  •  it is also known as an entry control loop.

  3. class WhileLoop { public static void main(String args[]) { // initialization expression int i = 1; // test expression while (i < 4) { System.out.println("Quipo House"); i++; // update expression } } } Program • class WhileLoop { • public static void main(String args[]) { • // initialization expression int i = 1; • // test expression • while (i < 4) { • System.out.println("Quipo House"); • i++; // update expression • } • } • }

  4. Features: • Condition-based Execution: • The while loop repeatedly executes a block of code as long as a specified condition is true. The condition is evaluated before each iteration, and if it becomes false, the loop terminates, and the program continues with the next statement after the loop. • Initialization and Increment/Decrement: • Typically, a while loop includes initialization of loop control variables before the loop starts and an increment or decrement operation within the loop body. These operations ensure that the loop eventually reaches a state where the condition becomes false, leading to termination. • Flexible Loop Structure: • The while loop is a versatile construct that allows for flexible loop structures. It is suitable for scenarios where the number of iterations is not known beforehand, and the loop continues until a specific condition is met. It provides control over the loop's execution based on the dynamic evaluation of the condition.

More Related