while 循环流程图int count = O:(循环继续条件)whilewhile (count<100) {Ⅱ循环体System.out.println("WelcometoJava!")语句(组)count++:count=0.LoopfalsefalseContinuation(count<100)?Condition?truetrueStatement(s)System.out.println("WelcometoJava!"(loopbody)count++,vO(B)(A)Liang,Introduction to Java Programming,Eighth Edition,(c)2011Pearson Education,Inc.Allrightsreserved.0132130807
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved. 0132130807 6 while 循环流程图 while (循环继续条件){ // 循环体; 语句(组); } int count = 0; while (count < 100) { System.out.println("Welcome to Java!"); count++; } Loop Continuation Condition? true Statement(s) (loop body) false (count < 100)? true System.out.println("Welcome to Java!"); count++; false (A) (B) count = 0;
动画跟踪while循环初始化countint count = O:while (count < 2) System.out.println("Welcome to Java!");count++:Liang.Introduction to JavaProgramming.EighthEdition,(c)2011Pearson Education,Inc.Allrightsreserved.0132130807
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved. 0132130807 7 跟踪while循环 int count = 0; while (count < 2) { System.out.println("Welcome to Java!"); count++; } 初始化 count 动 画
动画(续)跟踪while循环(count<2)为真int count = O:while(count<2)System.out.println("Welcome to Java!");count++:Liang.Introduction to JavaProgramming.EighthEdition,(c)2011Pearson Education,Inc.Allrightsreserved.0132130807
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved. 0132130807 8 跟踪while循环(续) int count = 0; while (count < 2) { System.out.println("Welcome to Java!"); count++; } (count < 2) 为真 动 画
动画(续)跟踪while 循环输出WelcometoJavaint count = O:while (count < 2) System.out.println("WelcometoJava!"count++:Liang,Introduction toJava Programming,EighthEdition,(c)2011Pearson Education,Inc.Allrightsreserved.0132130807
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved. 0132130807 9 跟踪 while 循环(续) int count = 0; while (count < 2) { System.out.println("Welcome to Java!"); count++; } 输出 Welcome to Java 动 画
动画(续)跟踪while循环count自增1int count = O:现在count是1while (count < 2) (System.out.println("Welcome to Java!count++:Liang,Introduction toJava Programming,EighthEdition,(c)2011Pearson Education,Inc.All10rightsreserved.0132130807
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved. 0132130807 10 跟踪 while 循环(续) int count = 0; while (count < 2) { System.out.println("Welcome to Java!"); count++; } count自增1 现在count 是1 动 画