Here is a Java Program to Demonstrate the Passed by Value
class Test {
void meth(int i, int j) {
i *= 2;
j /= 2;
}
}
This is a Main Class to run Above Java Class.
class CallByValue {
public static void main(String args[]) {
Test ob = new Test();
int a = 15, b = 20;
System.out.println("a and b before call: " +
a + " " + b);
ob.meth(a, b);
System.out.println("a and b after call: " +
a + " " + b);
}
}
Output of Above Java Program
a and b before call: 15 20
a and b after call: 15 20