// Code to add up some random int numbers in a 2D array. public class PoorCode { public PoorCode () { // Gets the current time in milliseconds since the start of 1970. long startTime = System.currentTimeMillis(); double[][] numArray = new double[1000][100]; int sum = 0; for (int i = 0; i < numArray.length; i++) { for (int j = 0; j < numArray[i].length; j++) { numArray[i][j] = (int)(Math.random() * 10); } } for (int i = 0; i < numArray.length; i++) { for (int j = 0; j < numArray[i].length; j++) { int value = (int)getValue(numArray, i,j); sum = sum + value; System.out.println("New sum = " + sum); } } long endTime = System.currentTimeMillis(); System.out.println("Program takes " + (endTime - startTime) + " milliseconds"); } public double getValue(double [][] numArray, int i, int j) { double value = 0; for (int m = 0; m < numArray.length; m++) { for (int n = 0; n < numArray[m].length; n++) { if ((m == i) & (n == j)) value = numArray[m][n]; } } return value; } public static void main (String args[]) { new PoorCode(); } }