programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering Languages Frameworks Products This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

# need help with another loop

nicky sajdok
Greenhorn
Posts: 14
Hello again
The code below prints out this
[7,4,2,1,0]
[9,8,6,5,3]

my problem now is that i want to put another loop inside of it so that my code will print this
ben
[7,4,2,1,0]
alex
[9,8,6,5,3]
this is my loop.

thanks
nicky

John Lee
Ranch Hand
Posts: 2545
You may have to do a triple loop, with {Ben, alex} at the outest, and manage to print the name just once.

nicky sajdok
Greenhorn
Posts: 14
and how would i do this?
thanks
nicky

John Lee
Ranch Hand
Posts: 2545
i=0; i<2; i++
{
if (j + k) == 0
{
print( array[i] )
}
j=0; j<4; j++
{
k=0; k<4; k++
{
}
}
}

William Barnes
Ranch Hand
Posts: 1049
2
What I think Don was saying.

nicky sajdok
Greenhorn
Posts: 14
I have tried your idea but i just cant seem to get it to work
thanks
nicky

William Barnes
Ranch Hand
Posts: 1049
2
If you need to understand how loops work I would suggest you start with a simpler demo example.

John Lee
Ranch Hand
Posts: 2545
Sorry for the bugs. I was in a hurry this morning.
To get this:
ben
[7,4,2,1,0]
alex
[9,8,6,5,3]

William Barnes
Ranch Hand
Posts: 1049
2
Not sure exactly what you are trying to show here, but the line

inside of this 'for'

doesn't make much sense to me.

John Lee
Ranch Hand
Posts: 2545
Here j==0 is extra. It looks like I can just print out the two statements.

 Don't get me started about those stupid light bulbs.