android - How is Java able to pass out parameter from method -


i came across not comprehend , never realized done.

i playing around block of code in android, , intrigued me this:

public boolean ontouch(view v, motionevent event){ rect outrect = new rect(); _btn.gethitrect(outrect); // ... rest of code cut // outrect fields of rect object 'filled' in. } 

how android's java can directly modify rect object outrect passed method in order obtain rect of button widget.

that surprised me, thought there no such thing 'pass reference' in java, in java parlance, using 'call-by-reference' rather, 'pass value' or 'call-by-value'?

yes, have read question asked before stumped, or android thing?

can shed light on this?

the outrect reference passed gethitrect method, modifies object referred outrect. references passed value.

for detailed explanation of this, read article: http://javadude.com/articles/passbyvalue.htm


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -