Why am I getting so many lines?
Code:
public class Loops
{
public static void main(String [] args)
{
for (int count = 1; count<15; count++)
{
for( int nextCount = 1; nextCount<15; nextCount++)
{
System.out.println("This line will print");
}
}
}
}
This nested loop should only execute 14 times for each loop, correct?
When I run the program, it ouputs "this line will print" what seems like way too many times, why is this?
Re: Why am I getting so many lines?
Well it should print it 14x14 times which is almost 200 times (196 to be exact)... How many does it seem like? :ehh:
Re: Why am I getting so many lines?
It looks like the line should print 196 (14x14) times. Does that sound about right?
Re: Why am I getting so many lines?
I gotcha, I was thinking that the loops would add 14+14, not multiply.
Thanks.