Skip to content

Commit 9b2b6ef

Browse files
committed
Rename arrays
1 parent 4057131 commit 9b2b6ef

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/com/codefortomorrow/intermediate/chapter10/solutions/Asterisks.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@
1414
public class Asterisks {
1515
public static void main(String[] args) {
1616
// create a 3x3 array
17-
String[][] b = new String[3][3];
17+
String[][] array = new String[3][3];
1818
String asterisks = "*";
1919
int numberOfAsterisks = 0;
2020

2121
// iterate through the 3x3 array
2222
for (int row = 0; row < 3; row++) {
2323
for (int col = 0; col < 3; col++) {
2424
// store the asterisk(s) in the array
25-
b[row][col] = asterisks;
25+
array[row][col] = asterisks;
2626

2727
// print the current element
28-
System.out.print(b[row][col] + "\t");
28+
System.out.print(array[row][col] + "\t");
2929

3030
// update total number of asterisks in array
3131
numberOfAsterisks += row + 1;

src/com/codefortomorrow/intermediate/chapter10/solutions/RandomNumbers.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ To call the method, type randInt(7, 77) and assign it to
2424

2525
public class RandomNumbers {
2626
public static void main(String[] args) {
27-
int[][] a = new int[4][6]; // create 4x6 array
27+
int[][] numbers = new int[4][6]; // create 4x6 array
2828
int sum = 0; // sum of all elements in array
2929
int max = Integer.MIN_VALUE; // max element in array
3030
int min = Integer.MAX_VALUE; // min element in array
@@ -34,21 +34,21 @@ public static void main(String[] args) {
3434
for (int col = 0; col < 6; col++) {
3535
// generate a random number from 7 to 77
3636
// and store it in the array
37-
a[row][col] = randInt(7, 77);
37+
numbers[row][col] = randInt(7, 77);
3838

3939
// print that element
40-
System.out.print(a[row][col] + "\t");
40+
System.out.print(numbers[row][col] + "\t");
4141

4242
// keep a running total of all elements
43-
sum += a[row][col];
43+
sum += numbers[row][col];
4444

4545
// update min or max as needed
46-
if (a[row][col] < min) {
47-
min = a[row][col];
46+
if (numbers[row][col] < min) {
47+
min = numbers[row][col];
4848
}
4949

50-
if (a[row][col] > max) {
51-
max = a[row][col];
50+
if (numbers[row][col] > max) {
51+
max = numbers[row][col];
5252
}
5353
}
5454
System.out.println(); // move to next row

0 commit comments

Comments
 (0)