4.6. Example Program: CheckerBoard.java

The following program will demonstrate using a two-dimensional array. It populates a checkerboard with red pieces and black pieces where they are supposed to go and prints it to the screen. This incorporates many of the programming structures we've looked at in this chapter, including loops, conditional logic, and two-dimensional arrays.

4.6.1. CheckerBoard.java

 /* File: CheckerBoard.java Purpose: demo using multidimensional arrays, loops, and conditional logic all in one. Prints a checker board. Author: E Hewitt */ import java.util.*; public class CheckerBoard { public static void main (String [] args) { // initialize some vars to loop with int x = 0; int y = 0; char board[][] = new char[8][8]; // populate ...

Get Java™ for ColdFusion® Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.