Skip to content

Instantly share code, notes, and snippets.

@twopoint718
Created June 2, 2009 02:58
Show Gist options
  • Save twopoint718/121955 to your computer and use it in GitHub Desktop.
Save twopoint718/121955 to your computer and use it in GitHub Desktop.
public class PrintArray
{
public static void main(String[] args)
{
// the basics of printing a 2d array
int[][] a = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
for (int i = 0; i < a.length; i++) {
int[] currRow = a[i];
for (int j = 0; j < currRow.length; j++) {
System.out.format("Item at (%d, %d) is %d\n", i, j, a[i][j]);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment