Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

How do you code this please in java

nesting loops

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1 Millie

Millie

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 09 April 2016 - 01:37 PM

Below are guidelines for posting a good programming question. Delete it before posting your topic!
I am trouble with nesting loops.  

I am trying to code this:

123456

23456

3456

456

56

  this is what i tried

 
    {
        for (int i=6;i<=6;i--)
        {System.out.println ();
            for (int j=1; j<=6; j++)
                System.out.print(j);
        }
    
 

 



#2 chili5

chili5

    CC Mentor

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3038 posts

Posted 10 April 2016 - 07:59 PM

You are somewhat close. You don't want the println at the beginning of the first loop (but after the second loop).

 

for (int i=6;i<=6;i--)

 

Your main problem is here this should be:

 

for (int i=6;i>=1;i--)