Lesson 18 – 2-D Arrays

Big Java 6

When you come in

  1. Connect to the Internet
  2. Log in to Piazza
  3. Start Bluej
  4. Navigate to laughton.com/obrien/sjsu/cs46a/CRT_lessons/ and open this lesson

Questions

Concept: 2D - Array

Concept - Processing a 2D array

 

Activity - Processing a 2D Array: sum

Record your participation in Piazza clicker question Lesson18 Q1

We are going to do some 2d array processing. Download this starter file.

Activity - More 2D array processing: max

Record your participation in Piazza clicker question Lesson18 Q2

We can use basically the same loops to implement other array processing algorithms

  1. Got it
  2. Got it, but it was hard
  3. Tried but did not get it in the time available
  4. Did not know where to start

 

Activity - Processing one row

Record your participation in Piazza clicker question Lesson18 Q3

What if we wanted to process only one row in IntArray2DProcessor?

  1. Got it
  2. Got it, but it was hard
  3. Tried but did not get it in the time available
  4. Did not know where to start

 

Activity - Initializing a 2D Array

Record your participation in Piazza clicker question Lesson18 Q4

Given an 8 × 8 array for a board game:
int[][] board = new int[8][8];

Finish the main method in the Board class and use nested loops to initialize the board so that zeros and ones alternate, like this

0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0
0 1 0 1 0 1 0 1
. . .
1 0 1 0 1 0 1 0

Hint: Check whether row + column is even.
  1. Got it
  2. Got it, but it was hard
  3. Tried but did not get it in the time available
  4. Did not know where to start

 

Activity - Printing a 2D Array

Record your participation in Piazza clicker question Lesson18 Q5

Add code to the main method of the Board class in the previous activity to print the board.

  1. Got it
  2. Got it, but it was hard
  3. Tried but did not get it in the time available
  4. Did not know where to start