Call by Value and Call by Reference in Java
Call by Value and Call by Reference in Java
There is only call by value in java, not call by reference. If we call a method
passing a value, it is known as call by value. The changes being done in the called
method, is not affected in the calling method.
class Operation{
int data=50;
op.change(500);
Output:
before change 50
after change 50
Ex:
class Operation2{
int data=50;
op.change(op);//passing object
Output:
before change 50