Do While, Break and Continue.ppt
Document Details
Uploaded by Deleted User
Full Transcript
1 5.5 do…while Repetition Statement do…while statement – Similar to while statement – Tests loop-continuation after performing body of loop i.e., loop body always executes at least once 1992-2007 Pearson Education, Inc. All rights reserved. 1...
1 5.5 do…while Repetition Statement do…while statement – Similar to while statement – Tests loop-continuation after performing body of loop i.e., loop body always executes at least once 1992-2007 Pearson Education, Inc. All rights reserved. 1 // Fig. 5.7: DoWhileTest.java 2 2 3 // do...while repetition statement. Outline 4 public class DoWhileTest Declares and initializes 5 { 6 public static void main( String args[] ) control variable counter 7 { DoWhileTest.java 8 Variable counter’s value is int counter = 1; // initialize counter displayed 9 before testing counter’s final value 10 do 11 { Line 8 12 System.out.printf( "%d ", counter ); 13 ++counter; Lines 10-14 14 } while ( counter