Skip to content

Commit 46127db

Browse files
author
Yalun Qin
committed
Add more 2d Array tests
1 parent 91624b1 commit 46127db

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

TestArray.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public static void main (String[] args) {
4444
System.out.println("Converted List = " + convertedList);
4545

4646
//Test 2d Array:
47+
//http://stackoverflow.com/questions/12231453/syntax-for-creating-a-two-dimensional-array
4748
int[][] nums = new int[][]{
4849
{},
4950
{1},
@@ -54,5 +55,12 @@ public static void main (String[] args) {
5455
for (int[] array : nums) {
5556
System.out.println("Original array: " + Arrays.toString(array));
5657
}
58+
int[][] nums2 = new int[4][7];
59+
for (int i = 0; i < nums2.length; ++i) {
60+
for (int j = 0; j < nums2[i].length; ++j) {
61+
System.out.print("(" + i + ", " + j + ")=" + nums2[i][j] + " ");
62+
}
63+
System.out.println("");
64+
}
5765
}
5866
}

0 commit comments

Comments
 (0)