I'd like to initialize 2 parameter in a method, in C++, I can do like this:
void setParam(int* width, int* height)
{
*width = getWidth();
*height = getHeight();
}
int w, h;
setParam(&w, &h);
How Can I do this in Java?
Printable View
I'd like to initialize 2 parameter in a method, in C++, I can do like this:
void setParam(int* width, int* height)
{
*width = getWidth();
*height = getHeight();
}
int w, h;
setParam(&w, &h);
How Can I do this in Java?
All objects in Java are passed by reference, but not primitives.
If you wan't to pass an integer by reference put the int in a class like java.lang.Integer
example:
Integer i = new Integer(1);
method(i);
public void method(Integer integer)