Java Nested Loops and Break Continue Methods

Day 12 & 13 A Journey with Edunet Foundation and Fayaz S Nested for loop:- ✒️A Nested For Loop in java is a for loop placed inside the body of another for loop ✒️The structure allows for multiple levels of iteration and is commonly used for tasks. Syntax:- for(initialization; condition; increment/ decrement){ for( initialization; condition; increment/decrement){ } } Day13:- Break and Continue, Methods in Java:- Break:- ✒️Break immediately terminates the loop or switch ✒️Control jumps to the statment after the loop/switch Ex:- for(int i = 0; i<=10; i++) { if(i==3) { break; } System.out.println(i); } Continue:- ✒️ Skips the current iteration and continuous with the next ✒️Control jumps to the next iteration of the loop. Ex:- for(int i=1; i<=10; i++) { if(i==3) { continue; } System.out.println(i); } Methods in Java:- ✒️Method in java is block of code that perform a specific tasks. ✒️Inseted of writing the same code again, we write it once inside a method a call it whenever needed. Syntax:- returntype methodName() { } #java #loops #corejava

  • text

To view or add a comment, sign in

Explore content categories