1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
package 控制语句;
public class TestBreak { public static void main(String[] args) { int total = 0; while(true) { int i = (int)Math.round(100*Math.random()); System.out.println(i); if(i==50) { break; } total++; } System.out.println("循环次数为:"+total); } }
|