+ 1

What is the difference between call by reference and call by variable in Java? If possible, implement one example.

15th Jul 2018, 10:48 PM
Emmanuel Kwesi Amankrah
Emmanuel Kwesi Amankrah - avatar
6 Respostas
+ 1
Call by value : It means you are passing arguments by its value means you are passing arguments copy to parameter. Now if parameter value is changed inside function it will not change actual arguments value. Example (C language): int increment (int a) //parameter { a+1; } int main() { int x=5; increment (x); //argument ......... /* here there will be no change to value of x even it is change in function i.e incremented*/ } Hope this helpsâ˜șâ˜ș.
16th Jul 2018, 9:14 AM
Meet Mehta
Meet Mehta - avatar
+ 1
Call by reference : It means you are passing arguments by its reference means you are passing arguments reference to parameter. Now if parameter value is changed inside function it will change actual arguments value. Example (C language): int increment (int *a) //parameter { *a + 1; } int main() { int x=5; increment (&x); //argument ......... /* here value of x will be changed if it is changed in function i.e incremented*/ } Hope this helpsâ˜șâ˜ș.
16th Jul 2018, 9:17 AM
Meet Mehta
Meet Mehta - avatar
+ 1
wow thank you
20th Jul 2018, 10:04 AM
Patricia Yu Hee Kim
Patricia Yu Hee Kim - avatar
+ 1
Patricia Yu Hee Kim and Emmanuel Kwesi Amankrah Most welcome. Happy this explanation help youâ˜șâ˜ș.
20th Jul 2018, 10:16 AM
Meet Mehta
Meet Mehta - avatar
0
Thank you very much.
17th Jul 2018, 10:26 PM
Emmanuel Kwesi Amankrah
Emmanuel Kwesi Amankrah - avatar
0
yeah it did
20th Jul 2018, 10:40 AM
Emmanuel Kwesi Amankrah
Emmanuel Kwesi Amankrah - avatar