I'm a little confused by what you're trying to do.
Here is the code, I had to replace i's and j's with j's and k's, to avoid HTML italicization:
First off, the syntax on your for-loops is incorrect. From the Java Language Specification
, "The for
statement executes some initialization code, then executes an Expression, a Statement, and some update code repeatedly until the value of the Expression is false." So to print the numbers from 0 to 9,
The name of your method is display(), but it looks like you are not only wanting to display the contents of the array, but also populate it with random numbers. Maybe you could split this population out into another method, and then call display() after the 2D array is loaded? And do you want the random integers that you populate the array with to be from 0 to 6, or 0 to 9? Also, you should cast Math.random()
to an int only after you multiply it by something, or you'll always get 0 as a result.
We'll be better able to steer you in the right direction if you tell us what you need this class to do, Douglas.