How to call a method once everyday?

How to call a method in a Java array, please help!?

  • I'm trying to compile my code here. I need to pass the two-dimensional array multTable to the method makeArray, however I keep getting the same error that tells me method makeArray in class multiplicationTable1 cannot be applied to given types; makeArray(multTable);. My code is listed below, please help me! public class multiplicationTable1 { public static void main(String[] args) { System.out.println ("Multiplication Table of 1's Through 9's"); int arraySize = 9; int[][] multTable; makeArray(multTable); printArray(multTable); } public static int [][] makeArray (int size) { //create a 2-dimensional array of int int[][] newArray = new int[size][size]; //populate array with values for(int row=0; row < newArray.length; ++row) for(int col=0; col < newArray.length; ++col) newArray[row][col] = (row + 1) * (col + 1); //return array to caller return newArray; } public static void printArray(int[][] newArray) { for(int row=0;row < newArray.length; ++row) for(int col=0; col < newArray.length; ++col) System.out.print("\t"+newArray[row]); System.out.println("\n"); } }

  • Answer:

    I see what you're trying to do. You want to give makeArrsy(..) just the size and have it return the array. This is what you wanted: int[][] multTable = makeArray(arraySize);

K4G3D at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

I see what you're trying to do. You want to give makeArrsy(..) just the size and have it return the array. This is what you wanted: int[][] multTable = makeArray(arraySize);

modulo_f...

Try setting multTable to null when you define the variable.

godfatherofsoul

Try setting multTable to null when you define the variable.

godfatherofsoul

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.