Skip to main content

Posts

Showing posts with the label java for loop

Nested for loop

Watch this on YouTube Watch part -2 A loop inside another loop is called the nesting of loops. So a for loop inside the body of another for loop is called a nested for loop. Nesting of for loop are essential for handling multidimensional arrays. Also nested for loop are needed for handling table of contents (rows & columns).    Syntax of a Nested for loop:                                                            for ( initialization ; condition ; updating)                                                         { // Starting of outer loop                                   ...

java for loop

Watch this on YouTube for loop in java is one of the most important control statement in java. Java for loop syntax: for (initialization ; condition ; updating) { statement / statements; } Initialization perform only once at the starting of the loop. It is also possible to initialize more than one variable at the same time but separates them with comma operator. (int i = 0, j = 1 ;)  Condition is always a Boolean statement. If more than one condition present, then separates them with any of logical operators.  Updating is generally an increment / decrements (++ / --) statement. First perform initialization and check the condition, if the condition is true then the loop body executes and then perform updating. Again check the condition, and if it is true again executes the loop body. This will continues till the condition become false. for loop example in java: import java.io.*; class ForDemo { publi...