动画(续)跟踪while循环因为count为1int count = O:所以(count<2)依旧为真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 11 跟踪while循环(续) int count = 0; while (count < 2) { System.out.println("Welcome to Java!"); count++; } 因为count为1 所以(count < 2) 依旧为真 动 画
动画(续)跟踪while 循环输出WelcometoJavaint count = O:while (count < 2) (System.out.println("WelcometoJava!"count++:Liang,Introduction toJava Programming,EighthEdition,(c)2011Pearson Education,Inc.All12rightsreserved.0132130807
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved. 0132130807 12 跟踪 while 循环(续) int count = 0; while (count < 2) { System.out.println("Welcome to Java!"); count++; } 输出 Welcome to Java 动 画
动画(续)跟踪while循环count自增1int count = O:现在count是2while (count < 2) (System.out.println("Welcome to Java!count++:Liang,Introduction toJava Programming,EighthEdition,(c)2011Pearson Education,Inc.All13rightsreserved.0132130807
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved. 0132130807 13 跟踪while循环(续) int count = 0; while (count < 2) { System.out.println("Welcome to Java!"); count++; } count 自增 1 现在count 是2 动 画
动画(续)跟踪while循环(count<2)为假int count = O;因为count现在是2while(count<2)System.out.println("Welcome to Java!");count++:Liang.Introduction to JavaProgramming.EighthEdition,(c)2011Pearson Education,Inc.All14rightsreserved.0132130807
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved. 0132130807 14 跟踪 while 循环(续) int count = 0; while (count < 2) { System.out.println("Welcome to Java!"); count++; } (count < 2)为假 因为 count现在是 2 动 画
动画跟踪while 循环退出循环。int count = O:执行循环之后的下一条语句while (count < 2) (System.out.println("Welcome to Java!")count++:Liang,Introduction toJava Programming,EighthEdition,(c)2011Pearson Education,Inc.All15rightsreserved.0132130807
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved. 0132130807 15 跟踪 while 循环 int count = 0; while (count < 2) { System.out.println("Welcome to Java!"); count++; } 退出循环。 执行循环之后的下一条语句。 动 画