标签:
break,contine都是使用在循环体中的语句,都有终止执行的作用,具体不同看下面详解。循环语句看这里:
break;
例子:
public class Test {
public static void main(String args[]) {
int [] numbers = {10, 20, 30, 40, 50};
for(int x : numbers ) {
if( x == 30 ) {
break;
}
System.out.println(x);
}
}
}这将产生以下结果:continue;
例子:
public class Test {
public static void main(String args[]) {
int [] numbers = {10, 20, 30, 40, 50};
for(int x : numbers ) {
if( x == 30 ) {
continue;
}
System.out.println(x);
}
}
}
这将产生以下结果:
10
Java技术_Java千百问(0020)_break与contine分别如何使用
标签:
原文地址:http://blog.csdn.net/ooppookid/article/details/51062446