Printing in a grid

Advertisement
hi
in my class i have a 2d which implements the random number generator
however at the moment it prints the information out in the form of a sentence
what i want is for the information in the array to be printed out in a table 8 across and 50 down
if anybody could help me with my code iv be very appreciative
thanks
import java.util.Random;
public class TwoDimensionArray
    public static void main(String args[])
        int[][] memoryArray=new int[50][8];
        Random randnum = new Random();
        for(int i=0;i<50;i++)
            for(int j=0;j<8;j++)
                memoryArray[i][j]=randnum.nextInt(32);
            for(int i=0;i<50;i++)
                    for(int j=0;j<8;j++)
                        System.out.println("the ["+i+"]["+j+"]element of the Array is: " + memoryArray[i][j]);
}
Advertisement

Replay

hey
thanks for the help
still this problem tho if you could help me resolve i would appreciate it very much
for(int i=0;i<50;i++)
                    for(int j=0;j<8;j++)
                        System.out.print("["+i+"]["+j+"]" + memoryArray[i][j]); //is this how you meant?
            //how do i insert a new line here?
            //iv tried System.out.println;
    }