break 文
コード public class ST_BREAK { public static void main(String[] args) { System.out.println("Start"); // System.out.println("------------------------"); int i =0; while(true) { i++; double dNum = Math.random(); if(dNum < 0.2 || dNum > 0.8){ System.out.println("SKIP " + i + "-> " + dNum); continue; } System.out.println("SKIP " + i + "-> " + dNum); if(i >= 30){ break; } } // System.out.println("------------------------"); System.out.println("End"); } }
結果 Start ------------------------ SKIP 1-> 0.06442781864507141 SKIP 2-> 0.12543261311030385 SKIP 3-> 0.4212817381974302 SKIP 4-> 0.09735041181973336 SKIP 5-> 0.4843277789878291 SKIP 6-> 0.3959124787947965 SKIP 7-> 0.1177907827529896 SKIP 8-> 0.8109545012195941 SKIP 9-> 0.2096486758269921 SKIP 10-> 0.6146085463959288 SKIP 11-> 0.8108961115067442 SKIP 12-> 0.48555181372959666 SKIP 13-> 0.9049434034349274 SKIP 14-> 0.8382490343622734 SKIP 15-> 0.32889128520077426 SKIP 16-> 0.4948166524523874 SKIP 17-> 0.12538348761238294 SKIP 18-> 0.9403935802228104 SKIP 19-> 0.7836134500742211 SKIP 20-> 0.7682335595626858 SKIP 21-> 0.43182533715372684 SKIP 22-> 0.9506752929921443 SKIP 23-> 0.837903495652499 SKIP 24-> 0.25986403043212347 SKIP 25-> 0.8416165954893343 SKIP 26-> 0.14138103333476526 SKIP 27-> 0.6296223172489991 SKIP 28-> 0.13919813477934484 SKIP 29-> 0.6359252410858568 SKIP 30-> 0.24665447261527107 ------------------------ End