break 语句用于跳出循环. for (i=0;i<10;i++) { if (i==3) { break; } x=x + "The number is " + i + "<br>"; } continue 用于跳过循环中的一个迭代. for (i=0;i<10;i++) { if (i==3) break; x=x + "The number is " + i + "<br>"; }
package test; public class Loop_Statement { public static void main(String [] args) { String[] newbag = new String[] {"Bag","Key","Book"}; //The usage of break int j = 0; while (j<newbag.length) { if(newbag[j] == "Key
区别 break和continue都可在循环语句里面使用,也都可以控制外层的循环.但是continue只能在循环语句里面使用,break也可以使用在switch语句里面. break具体作用在循环语句中的具体作用是,跳出当前循环,当然还可以跳出所有的循环.当前循环中break语句之后的语句都不会执行. break跳出当前循环: public class Test { public static void main(String[] args) { //循环打印1,2,3,4 for (int i