Hi Friend, run this code, and check out the console:

public class ForLoop{

        public static void main (String[] args){
                for(int i = 1;i <= 5;i++){
                        for(int j = 1;j <= i;j++){
  System.out.println("When i = "+i+ " then j ="+j);
                        }
                }
        }

}

As you see, the inner for is executed i times, that's  value of i is
4, then the inner for is executed 4 times and so..




On Sep 25, 7:28 pm, Pravglad <[email protected]> wrote:
> for(int i = 1;i <= 5;i++){
>       for(int j = 1;j <= i;j++)
>
> can someone explain me how this works please

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en

Reply via email to