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

  • Home
  • SEARCH
  • 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 8808119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:32:30+00:00 2026-06-14T02:32:30+00:00

is it expensive to always pass Activity as an argument to a method? You

  • 0

is it expensive to always pass Activity as an argument to a method?

You see, I have this class (this is where I put the commonly used methods by my activities). And all my methods there have Activity as a parameter, because the results of those methods will need to be send back to the activity that invoked the method, so basically I need to know to whom should I throw back the results, so I always have like:

public static void processThis(Activity activity){ 
// some Code
}

I just like to know if this is against the best practices or if this is expensive to use?

Thanks. Looking forward for your explanations that will enlighten me.

Added:
I’m extracting commonly used methods from my activities to promote code reuse. Like, ActivityA use methodA and send broadcast back to ActivityA, same way goes for ActivityB which uses methodB(same as methodA) and send broadcast back to ActivityB. So what I want to achieve is to to extract that methodA and methodB which basically are the same, and put them into another class, and add a parameter Activity so I can know to whom do I need to send the broadcast back. Thanks.

  • 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-14T02:32:31+00:00Added an answer on June 14, 2026 at 2:32 am

    In Java, all parameters that are not primitives are implicit pointers; consequently, passing an object such as activity only requires passing around the address at which the Activity is located in memory, so passing such a thing is not an expensive thing to do in Java.

    So, the real question you should ask yourself is not whether it is expensive, but rather if it makes the most sense (from a logical / maintainability perspective). If it makes sense, then by all means do it.

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

Sidebar

Related Questions

In the source code of Activity.java, I see some methods bellow : public View
I have always read that creating threads is expensive. I also know that you
My app has an expensive service method, results of which must be 1) checked
I have an expensive query using the row_number over() functionality in SQL Server 2005.
I have a computationally expensive task in perl, and would like to inform the
I have a very expensive query which gets executed from php and it can
I have an expensive server side resource ( which is thread safe ). What
I have a few computationally expensive properties on some classes. These properties do not
I have always been taught that non-primitive types should be passed by const reference
This is a compiler error (slightly changed for readability). This one always puzzled me.

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.