Here x is reference variable of an instance of class XCopy, which holds the reference of an object of class XCopy.
In below code your calling instance method go(int arg) and passing orig as int parameter whose value is 42 (int).
Below int go(int arg) is an instance method whose return type is int means method must return int value.
Here arg is local variable of method go, value of variable orig is copied in local variable arg of method go().
(Note: No operation on orig variable so value of orig will be same as it is i.e. 42)
Now arg = 42.
Here arg = arg * 2; means arg = 42 * 2 so arg becomes 84. and
returns arg variable's value i.e. 84 to the point where it was called from so control goes to here
and assigns 84 value in variable y so now y = 84. Then you printed it
prints value of orig which is 42 and value of y i.e. 84 which you got by
Being Java programmer.
Poop goes in a willow feeder. Wipe with this tiny ad: