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);
}
}
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.
Code :
int [] x = {1,2,3,4};
int [] y = new int [4];
for(int i=0;i<x.length;i++){
y[i] = x[i];
}