How to change variable value passed by argument?

A

Allen

In C++, we can do it like this:

void Square(int& value)
{
value *= value;
}

How can I do it in Java?

I try the following method, but it does not work.

void square(Integer value)
{
value = value * value;
}
 
M

Mark P

Allen said:
In C++, we can do it like this:

void Square(int& value)
{
value *= value;
}

How can I do it in Java?

I try the following method, but it does not work.

void square(Integer value)
{
value = value * value;
}

Why would you ask this in a C++ group? comp.lang.java
 
A

Alan Johnson

Allen said:
It is a java question. Why ask it in C++ group?

That was precisely Mark P's point. This is comp.lang.c++ (i.e. a C++
group), and you asked a Java question here. Why would you do that?
 
A

Allen

That was precisely Mark P's point. This is comp.lang.c++ (i.e. a C++
group), and you asked a Java question here. Why would you do that?


Oh. Sorry, I post it in C++ group.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top