October 2017
Beginner
318 pages
7h 26m
English
If you've followed along thus far, let's go ahead and write the final bit of our program, a line of code to print out our chessboard to the screen. Actually, we're going to need a bit more than a line of code. We can use the println() function along with arrays.toString() to print the contents of a single array to the screen, but this technique won't work well with a two-dimensional or higher array.
So, we're going to need to use a for loop again to grab each array in turn, and then print them to the screen. This works pretty well because println will automatically carriage return, or give us a new line between each row we print. Here, let's use the conventional syntax variable i to iterate through our for loop:
Read now
Unlock full access