When I'm iterating over two arrays at once, which one do I use as the limit?
- by Martijn Courteaux
Hi,
I'm always struggling with something like the following Java example:
String breads[] = {"Brown", "White", "Sandwich"};
int count[] = new int[breads.length];
for (int i = 0; i < ****; i++)
{
// Prompt the number of breads
}
****: which array.length should I choose?
I can choose between breads.length and count.length
I know it would be the same result, but I don't know which one I shoud choose.
There are many other examples where I get the same problem.
I'm sure that you have encountered this problem as well in the past.
What should you choose? Are there general agreements?
Thanks