Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8203539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:35:33+00:00 2026-06-07T07:35:33+00:00

I came across something that I could not comprehend and never realized it could

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T07:35:35+00:00Added an answer on June 7, 2026 at 7:35 am

    The outRect reference is passed to the getHitRect method, which then modifies the object referred to by outRect. References are passed by value.

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

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I came across something that seems unusual and I was wondering if anyone could
I've came across something that drives me crazy. please help me :( I'm try
Came across something like this today, and was wondering if there was an equivalent
So while rewriting some code, I came across something along the lines of: Method
Came across this code: <?php require_once 'HTTP/Session/Container/DB.php'; $s = new HTTP_Session_Container_DB('mysql://user:password@localhost/db'); ini_get('session.auto_start') or session_start();
I came across this comparison chart that suggests that FMS costs about 4.5 grands
I came across a few articles like this one , which suggest that some
I came across this question: https://softwareengineering.stackexchange.com/questions/87077/how-can-a-code-editor-effectively-hint-at-code-nesting-level-without-using-inde and thought that Vim might be able to
Some time ago, I came across a piece of code, that used some piece
Came across a problem which google searches could not help me with. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.