Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Nested for loops and array

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Nested for loops and array

    Hi, I want help in figuring out how to set a line[0] for example to windows[0], line[1] to windows[1] etc.
    If theres a single line[0] but multiple windows it sets that line to multiple windows correctly, i just can't get
    how to set a line to each window if there is multiple lines.
    (Its a Theater simulator that I'm writing)

    Heres the block of code that handles that

    for(int j = 0; j < numOfWindows; j++)
    {
    int windowTime = reader.nextInt(); //Disregard this.
    for(int i = 0; i < lines.length; i++)
    {
    windows[j] = new TicketWindow(null, lines[i], windowTime);

    }
    }


  2. #2
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: Nested for loops and array

    The given code doesn't specify what is windows and lines data type.
    Well, here is the example. May be this could help you out.
    int [] x = {1,2,3,4};
    int [] y = new int [4];
    for(int i=0;i<x.length;i++){
             y[i] = x[i];
    }

Similar Threads

  1. Nested for loops
    By Fordy252 in forum Loops & Control Statements
    Replies: 2
    Last Post: December 8th, 2012, 11:43 PM
  2. Using Nested Loops
    By m2msucks in forum Loops & Control Statements
    Replies: 7
    Last Post: November 5th, 2011, 08:05 PM
  3. [SOLVED] Nested Loops & Processing Strings
    By Usoda in forum What's Wrong With My Code?
    Replies: 20
    Last Post: October 20th, 2011, 08:15 PM
  4. Help with Nested Loops
    By Plural in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 23rd, 2010, 04:31 PM
  5. how do i draw a shape with nested loops?
    By Kilowog in forum Loops & Control Statements
    Replies: 1
    Last Post: September 25th, 2009, 01:14 AM