Help with a 2D array maze

Hi, I'm trying to create a maze that characters can run around in, I think that I've got the basics done but I need more specific help. My code:

publicclass maze{

/** Creates a new instance of maze */

publicvoid maze(String[] args){

int[][]maze =newint[][]{

{0,1,0,0,0,0,0,0,0},

{0,1,1,1,1,1,1,1,0},

{0,0,0,0,0,0,0,1,0},

{0,1,1,1,1,0,0,1,0},

{0,1,0,0,1,1,1,1,0},

{0,1,1,0,0,0,0,0,0},

{0,1,0,0,1,1,1,1,0},

{0,1,0,0,1,0,0,1,0},

{0,1,1,1,1,0,0,1,0},

{0,0,0,0,0,0,0,1,0}};

for (int i=0; i < maze.length; i++){

for (int j=0; j < maze[i].length; j++){

System.out.print(maze[i][j]);

}

System.out.println();

}

}

Well that's it, as you can see it really is just an array; what do I need to do to make it print out "*" instead of 0s and " " instead of 1s (0s are meant to be walls and 1s the passage way), and how should I go about doing it.

If anyone could help that would be great.

Thanks in advance.

[2207 byte] By [Gatchasama] at [2007-10-3 11:54:51]
# 1
An if statement?
CaptainMorgan08a at 2007-7-15 14:29:48 > top of Java-index,Other Topics,Java Game Development...
# 2

Faster than an if statement, if you are up to learning it, is the use of the ternary operator.

It's syntax is like this:

condition ? value1 : value2

where condition is a boolean expression, value1 is the expression to be evaluated and returned if and only if condition is true, and value2 is the expression to be evaluated and returned if and only if the condition is false.

Your line of code would be something like:

System.out.print(maze[i][j] == 0 ? "*" : " ");

Edit: I am not assuming people are newbies when they are, I realize this.

Message was edited by:

Aken_Bosch

Aken_Boscha at 2007-7-15 14:29:48 > top of Java-index,Other Topics,Java Game Development...
# 3
> Faster than an if statement, if you are up to> learning it, is the use of the ternary operator.What do you mean by faster?
prometheuzza at 2007-7-15 14:29:48 > top of Java-index,Other Topics,Java Game Development...
# 4

Do you mean faster to write, or faster to run?

I thought the ternary syntax and an if-statement would evaluate to the same bytecode in cases where it did the same

ie. that

return (var == test) ? x : y

is equivalent to

if (var == test) {

return x;

} else {

return y;

}

TomasEkelia at 2007-7-15 14:29:48 > top of Java-index,Other Topics,Java Game Development...