displaying a twodimensional array

publicvoid printGrid()

{

for (int i = 0; i < gridSize; i++)

{

for(int j = 0; j < gridSize; j++)

{

System.out.println = grid[i][j];

}

}

}

i need help in displaying the information on a grid, the above code is just part of the code i'm working on,it is a two dimensional array, but i can't get the grid to display it's value as below

_ _ _ _ _

_ _ _ _ _

_ _ _ _ _

_ _ _ _ _

_ _ _ _ _

can someone help me out please.

thanks

Message was edited by:

marxy007

[950 byte] By [marxy007a] at [2007-11-27 10:59:00]
# 1

> [code]

> public void printGrid()

>{

>for (int i = 0; i < gridSize; i++)

>{

>for(int j = 0; j < gridSize; j++)

>{

> System.out.println = grid[j];

>

>

>}

> ode]

> i need help in displaying the information on a grid,

> the above code is just part of the code i'm working

> on,it is a two dimensional array, but i can't get the

> grid to display it's value as below

>

> _ _ _ _ _

> _ _ _ _ _

> _ _ _ _ _

> _ _ _ _ _

> _ _ _ _ _

>

> can someone help me out please.

>

> thanks

>

> Message was edited by:

> marxy007

What are you getting instead? Make sure GridSize is not 0;

snic.snaca at 2007-7-29 12:20:07 > top of Java-index,Java Essentials,Java Programming...
# 2

This line won't compile:

System.out.println = grid[i][j];

I'd have more faith in your code is you posted what you're actually using...

Hippolytea at 2007-7-29 12:20:07 > top of Java-index,Java Essentials,Java Programming...
# 3

Java 6 has a Console class for console print formatting:

http://java.sun.com/javase/6/docs/api/java/io/Console.html

Without it you might have to goof your way around with:

System.out.println("" + number + "\t");

TuringPesta at 2007-7-29 12:20:07 > top of Java-index,Java Essentials,Java Programming...