I came across something that I could not comprehend and never realized it could be done.
I was playing around with this block of code in Android, and what intrigued me was this:
public boolean onTouch(View v, MotionEvent event){
Rect outRect = new Rect();
_btn.getHitRect(outRect);
// ... rest of code cut
// outRect fields of that Rect object is 'filled' in.
}
How is it that Android's Java can directly modify a Rect
object outRect
which was passed into the method in order to obtain the Rect
of a button widget.
That surprised me, as I thought there was no such thing as 'pass by reference' in Java, in Java parlance, using a 'call-by-reference' rather, its 'pass by value' or 'call-by-value'?
Yes, I have read this question asked before but am stumped, or is that an Android thing?
Can anyone shed some light on this?