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 7503571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:16:15+00:00 2026-05-29T21:16:15+00:00

I am newbie in java/android. I am a c/c++ developer. May i know how

  • 0

I am newbie in java/android. I am a c/c++ developer. May i know how to pass a reference as parameter in android. An illustrative c sample code shown below

void main()
{
  int no1 = 3, no2 = 2, sum = 0;
  findsum( no1, no2, sum );
  printf("sum=%d", sum );
}

void findsum( int no1, int no2, int& sum )
{
  sum = no1 + no2;
}

please suggest me a solution

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-05-29T21:16:17+00:00Added an answer on May 29, 2026 at 9:16 pm

    You cannot pass an int as reference in Java. int is a primary type, it can be passed only by value.

    If you still need to pass an int variable as reference you can wrap it in a mutable class, for example an int array:

    void findsum( int no1, int no2, int[] sum )
    {
      sum[0] = no1 + no2;
    }
    

    Anyway, I strongly suggest you to refactor your code to be more object oriented, for example:

    class SumOperation {
       private int value;
    
       public SumOperation(int no1, int no2) {
          this.value = no1 + no2;
       }
    
       public int getReturnValue() { return this.value; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm learning Java, and I know one of the big complaints about newbie programmers
I am a newbie to Android and Java and want to write a function
Java newbie here, I'm having trouble setting a new line in this code: String
Newbie to C++ learning by converting a java program to c++. The following code
I am a total newbie when it comes to both java and android coding.
I'm a completely newbie to android programming, having done some java for my computing
I know Java apps can be run in Android. But what I want to
I am a complete newbie with Java. I use notepad++ to write Java code,
I'm a complete newbie to Android, and this may actually be more of a
I'm a newbie to Java, but somewhat familiar to C. I wanted to know

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.