// TwoDArray4.java // A program to illustrate 2D array parameter passing // // here is a possible data.txt // // 17 3 2 13 // 5 10 11 8 // 9 6 7 12 // 4 15 14 1 // public class TwoDArray4 { public static void main (String[] args) { final int MAX = 4; int[][] grid = new int[MAX][MAX]; loadTable(grid); printTable(grid); } static void loadTable (int[][] lTable) { TextReader inFile = new TextReader("data.txt"); for (int row = 0; row < lTable.length; row++) for (int col = 0; col < lTable[row].length; col++) lTable[row][col] = inFile.readInt(); } static void printTable (int[][] pTable) { System.out.println("\n\n"); for (int row = 0; row < pTable.length; row++) { for (int col = 0; col < pTable[row].length; col++) System.out.print(Format.right(pTable[row][col],4)); System.out.println(); } System.out.println("\n\n"); } }