Putting this out there for anyone brave enough to try to nearly draw me a picture, cause I'm just not getting part of this:
Some of the comments are my own..please correct them as needed. I'm not getting the action of the two sets of nested for loops. The way I'm reasoning this is that the "boxes" (from a visual representation) is being counted and thus outputs 0-9 and in an uneven dimension. I understand the lines that initialize the second dimension. I just don't understand *precisely* what the for loops are doing other than incrementing from 0-9. Can someone comment the for loops for me to clarify? Thank you.>
I think I just need to see this visually or something, because I'm not understanding why it's using two sets of nested for loops. Could this example possibly use only 1 nested for loop to get the same result? Everything web site, or video I've watched on 2d arrays use only 1 set of for loops.
a 1 dimensional array is an egg carton. Eggs are what I care about, but an egg carton holds them, and I can make an egg carton of any size.
a 2 dimensional array is a crate of egg cartons. the crate can hold any number of egg cartons, as long as I make it big enough. Each egg carton can then be a different size. One egg carton in my crate may hold 6 eggs, and the next may hold 12. So, the first loop has me look at each egg carton in the crate. The inner loop looks at each egg in the carton I'm currently looking at. Each time I move to a new egg carton, I need to start over and look at each egg. That's why I need the loop inside the loop.
The analogy can continue to higher dimensions:
A palate of crates of cartons of eggs
A truck full of palates full off crates of cartons of eggs
a fleet of trucks full of trucks full of palates full of crates full of cartons full of eggs...
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors