Given the following code:
Rect pos = new Rect();
for (int i = 0; i < mCols; i++) {
pos = mTiles[1][i].getmPos();
pos.top = pos.top - size;
pos.bottom = pos.bottom - size;
mTiles[0][i].setmPos(pos);
}
What I want to do is get the value from
mTiles[1][i].mPos
modify it, and set it in
mTiles[0][i].mPos
The problem is this statement
pos = mTiles[1][i].getmPos();
is copying the reference to the object and not the value of the object. Meaning, when I modify pos.top or pos.bottom, the original object gets modified.
I'm guessing I am missing a concept of pass object by reference vs value here...which I thought I understood. What is the fix here? Is it a problem with how I defined my custom class?
Thanks.