I thought when you passed objects to methods in Java, they were supposed to be by value.
Here is my code:
public class MyClass{
int mRows;
int mCols;
Tile mTiles[][]; //Custom class
//Constructor
public MyClass(Tile[][] tiles, int rows, int cols) {
mRows = rows;
mCols = cols;
mTiles = new Tile[mRows][mCols];
for (int i=0; i < mRows; i++) {
for (int j=0; j < mCols; j++) {
mTiles[i][j] = new Tile();
mTiles[i][j] = tiles[i][j];
}
}
}
At this point, any changes to the mTiles
object are reflected back to the tiles object. Any ideas how to fix this?
Thanks all.
No comments:
Post a Comment