Help nested loop?

Home » Programming & Design » Help nested loop?
Programming & Design No Comments

Other answer:

Bhadresh:
If you wanted it to display 13 instead of 4 then you'd need

System.out.print ("" + i + j + " ");

If the print () starts with a String then it assumes that the plus signs are concatenating (joining) strings instead of doing addition.

It will only print 6 items.
i will be 1, 2 and 3, NOT 4

david:
I have to ask. Is there a reason why you can't just cut and paste this code in to a compiler and SEE what the output is? Because that seems like it would be trivial to do.
Bhadresh:
What is the output of the nested for loop below?

Find output
for(int i=1; i<4; i++)
{
for(int j=3; j>1; j–)
System.out.print( i + j + " "); // " " is a space
}

LEAVE A COMMENT