Basic C++ vs Java question

So, apparently in Java everything is done with references...objects are never passed by value...only their pointers are passed by value. So what happens here?


void function (int x)
{
x = 3;
}


int z = 2;
function(z);
system.out.println(z);


In other words, did the value of z get changed to 3 because it was passed by reference, or did it stay at 2 because x is just a temporary variable from value?
In Java primitive types (like int, float, double...) are passed by value.
Topic archived. No new replies allowed.