Array2D

Array2D - * it's row and its column. */ public void...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.util.Scanner; /** * Class to experiment with two-dimensional arrays. * * @author K. Murray */ public class Array2D { private int[][] arr2D; private static final int ROWS = 5; private static final int COLUMNS = 7; /** * Constructor for objects of class Array2D */ public Array2D() { arr2D = new int[ROWS][COLUMNS]; for (int row = 0; row < ROWS ; row++) for (int col = 0; col < COLUMNS; col++) arr2D[row][col] = 0; } /** * Set a single cell in the array to given value by specifying
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: * it's row and its column. */ public void setArray(int row, int col, int value) { arr2D[row][col] = value; } /** * print the arr2D array */ public void printArr2D() { printArray(arr2D); } /** * print an array of ints */ private void printArray(int intArray) { for (int row = 0; row &lt; intArray.length; row++) { for (int col = 0; col &lt; intArray[row].length; col++) { System.out.print(intArray[row][col] + &quot; &quot;); } System.out.println(); } } }...
View Full Document

Page1 / 2

Array2D - * it's row and its column. */ public void...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online