call me Bill
I am being told that the output from the outer loop is 20 and 21,
the inner loop output is 30 and 31.
Bill Platt wrote:It is my understanding the at outer loop * inner loop will cause the inner loop to iterate that number of times
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Junilu Lacar wrote:Who is telling you this?
The output of this code is this:
Junilu Lacar wrote:
Note that because you have a String as the first term in the expression that is the argument to System.out.print(),
what's occurring is String concatenation, not integer addition.
call me Bill
Campbell Ritchie wrote:Also avoid <= if you can.
call me Bill
Yes, but <= is much easier to misread than <, and < is what people expect to see.Bill Platt wrote:. . . Doesn't the use of <= or any other operator depend upon each specific situation?
But as you know it is bad form to use number literals like that. At least provide an explanation of what the numbers mean in a comment.Most of us are used to starting from 0 and working up to a limit, exclusive. It is much easier to see that the last loop will run 8× than to see that 3...10inclusive means 8×.. . . between 3 and 10 (inclusive) . . . Bill
Campbell Ritchie wrote:Yes, but <= is much easier to misread than <, and < is what people expect to see.
But as you know it is bad form to use number literals like that. At least provide an explanation of what the numbers mean in a comment.Most of us are used to starting from 0 and working up to a limit, exclusive. It is much easier to see that the last loop will run 8× than to see that 3...10inclusive means 8×.. . . between 3 and 10 (inclusive) . . . Bill
call me Bill
All things are lawful, but not all things are profitable.
Campbell Ritchie wrote:but computers start counting from 0.