> When I do this
> char[][] board;
[quoted text clipped - 9 lines]
> For some reson both board AND tmpBoard has been changed and looks the
> same. I would expect only tmpBoard to have changed - am I wrong?
Yes. Variables in Java (except primitives like int) are pointers to objects,
not objects themselves. tmpBoard and board both point to the same array;
you're not changing "tmpBoard", you're changing the object to which "tmpBoard"
points, which is the same as the object to which "board" points.
board --->{array in memory}
tmpBoard ---^

Signature
Lew
aDeamon - 23 May 2007 16:16 GMT
> > When I do this
> > char[][] board;
[quoted text clipped - 20 lines]
> --
> Lew
Tanks it help to create a new variable.
aDeamon - 23 May 2007 16:17 GMT
> > When I do this
> > char[][] board;
[quoted text clipped - 20 lines]
> --
> Lew
Tanks it help to create a new variable.
aDeamon - 23 May 2007 16:17 GMT
> > When I do this
> > char[][] board;
[quoted text clipped - 20 lines]
> --
> Lew
Thanks it help to create a new variable.
aDeamon <stud1980@hotmail.com> wrote in news:1179930938.868379.56420
@q69g2000hsb.googlegroups.com:
> When I do this
> char[][] board;
[quoted text clipped - 11 lines]
>
> /Sam
I don't see any other replies to this one, so I will take a shot at it.
You are wrong.
The line
tmpBoard = board
does NOT copy the contents of an array from one place to another.
'board' references (points to) an array, and now 'tmpBoard' references
(points to) the SAME array. Changes to one are changes to the other because
there is NO other, they reference the same thing.
You need to allocate an array for 'tmpBoard' and use loops to copy from
'board' to 'tmpBoard'. You could also use java.lang.System.arraycopy(...)
but it may not help much because your arrays have multiple dimensions.

Signature
Ian Shef 805/F6 * These are my personal opinions
Raytheon Company * and not those of my employer.
PO Box 11337 *
Tucson, AZ 85734-1337 *