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