Results 1 to 5 of 5

Thread: Nested loops?

  1. #1
    gabriel is offline Member
    Join Date
    Jul 2007
    Posts
    41
    Rep Power
    0

    Default Nested loops?

    What are nested loops and when do I use them?
    Can you teach me through an example?
    I will appreciate that
    thanks guys

  2. #2
    yiweiang is offline Member
    Join Date
    Aug 2007
    Posts
    15
    Rep Power
    0

    Default

    Java Code:
    public class Text1 {
    
        public static void main(String Args[])
        {
        	for(int x=0; x<10; x++)
    			{
         		for(int y=0; y<10; y++)
         			{
          			System.out.println(x+", "+y);
          			
         			}
    			}
        }
        
        
    }
    Last edited by levent; 08-03-2007 at 03:14 PM. Reason: Code placed inside [code] tag.

  3. #3
    levent Guest

    Default

    Hi yiweiang,

    You can place your code inside [code] tag. It will make our codes much more readable.

  4. #4
    yiweiang is offline Member
    Join Date
    Aug 2007
    Posts
    15
    Rep Power
    0

    Default

    A nested loop is basically a loop in a loop. So the x loop runs once, y runs 10 times. Then x runs the second time, and y runes 10 times. etc.

  5. #5
    gabriel is offline Member
    Join Date
    Jul 2007
    Posts
    41
    Rep Power
    0

Similar Threads

  1. Question about loops
    By BHCluster in forum New To Java
    Replies: 4
    Last Post: 04-16-2008, 05:40 PM
  2. Breaking from nested switch
    By javaplus in forum New To Java
    Replies: 3
    Last Post: 02-02-2008, 08:28 AM
  3. Loops (while do etc)
    By manupr in forum New To Java
    Replies: 1
    Last Post: 01-15-2008, 03:59 AM
  4. Nested For Loop
    By yuchuang in forum New To Java
    Replies: 1
    Last Post: 07-08-2007, 01:11 PM
  5. Nested Tags JSP
    By Marcus in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 06-25-2007, 05:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •