+ 1
I could not figure it out.
how this works. public class Program { public static void main(String[] args) { int i,j; for(i=1;i<4;i++){ for(j=1;j<2;j++){ System.out.println("v"); System.out.println("8"); } } } }
4 Answers
+ 11
first loop is execute 3 time for i=1,2,3
and second for loop is execute one time because 1<2 so only one time condition true and loop body executed so
for i = 1 the inner loop print
v,8
for i = 2 the inner loop print
v,8
for i = 3 the inner loop print
v,8
so output came as v 8 v 8 v 8
+ 7
I donât know exactly what you want, but itâs basically two loops, one inside the other, or nested, printing out v and 8.
if the first for statement is true, it moves to the second for statement, which prints the v and 8 out.
+ 2
thank q pal
+ 2
In this code there are two nested for loops. First the inner loop iterates, after the loop ends the outer loop is iterating one time and again the inner loop starts.You can read more here https://study.com/academy/lesson/nested-for-loops-in-java.html