Jumping statments are used to jump the control to any line in between the program. It can stop the termination of loop, skip the statement or even exit from any function.
Types of Jumping Statements are:
Break is a keyword used inside a loop to terminate the execution of a loop.
for (i=1; i<=10; i++) { if (i==5) break; System.out.println("Hello"); }
Continue statement is use to skip the statements but control remains in execution.
for (i=1; i<=10; i++) { if(i==5) continue; System.out.println("Hello" + i); }
Return is mostly used to return the control back to the function call. It can return with or without value.
Example of return statement will be discuss in user-defined method topic.
Return is mostly used to return the control back to the function call. It can return with or without value.
Loop1: for (i=1; i<=10; i++) { Loop2: for (j=1; j<=10; j++) { System.out.println("Hello"); if (j==5) break loop1; } }