return
写在 main
方法,退出程序,后面的代码不再执行。Return01.java
public class Return01 {
public static void main(String[] args) {
for (int i = 1; i <= 5; i++){
if (i == 3){
System.out.println("兮动人"+i);
return;
}
System.out.println("Hello World!");
}
System.out.println("go on...");
}
}
break
,执行结果为:
continue
结果为: