Code in Loop What Happens
break Execution jumps immediately to the 1st statement after the for loop.
return Execution jumps immediately back to the calling method.
System.exit() All program execution stops; the VM shuts down.
public class MainClass{
public static void main(String[] argv){
System.out.println();
}
static boolean doStuff() {
for (int x = 0; x < 3; x++) {
System.out.println("in for loop");
return true;
}
return true;
}
}
|