I cant get this to work. Im trying to count how many times a number s put into the location of a multidimensional array...I will bold what I mean:
import java.util.*; public class Assign1b { //------------------------------- // Variable Declaration //------------------------------- static int[][] dataArray = new int [10][10]; //Creates a ten by ten integer array public static void arrayFiller(int[][] inputArray) { //Input: Accepts a 2D integer array as a parameter. //Output: This method does not print any arrays. //Return: This method does not return anything. //Descr: This method fills an array with random numbers. Random generator = new Random(); //creates a generator object from the random class //for loops that fills array. for(int col = 0; col < dataArray.length; col++) { for (int row = 0; row < dataArray[col].length; row++) { dataArray[col][row] = generator.nextInt(26); [B]digitCount[(dataArray[col][row])]++;[/B] ^ | //can I do this? say the number at dataArray[1][1] is 13...can I add a count to a location in digit count like this? or how would I do it? I want to do it as soon as each random number is put into the 2D array as I believe this would be much easier. Thanks in advance!!! }//end of inner for loop }//end of outer for loop }//end of arrayFiller() public static void print2DArray (int[][] newArray) { //Input: This method accepts a 2D array as a parameter. //Output: This method prints out the 2D array filled with random numbers. //Return: This method does not return anything. //Descr: This method prints out the 2D array filled with random numbers. //Prints out header System.out.print ("Array: dataArray |"); for (int z = 1; z <= newArray[0].length; z++) { System.out.printf("%5d", z); }//end of for loop System.out.print(" |\n"); System.out.print(" \t\t\t\t"); for (int q = 0; q <= newArray[0].length; q++) { System.out.print("-----"); }//end of for loop System.out.println(); //Prints out body for (int x = 0; x < newArray.length; x++) { System.out.printf("%16d |",(x + 1)); for(int y = 0; y < newArray[x].length; y++) { System.out.printf("%5d",newArray[y][x]); }//End of inner for loop System.out.print(" |\n"); }//End of outer for loop //Prints out footer System.out.print(" \t\t\t\t"); for (int q = 0; q <= newArray[0].length; q++) { System.out.print("-----"); }//end of for loop }//end of print2DArray() public static void main (String[] args) { arrayFiller(dataArray); print2DArray(dataArray); }//End of main() }//End of class: Assign1b