| Author |
please explain
|
vineet walia
Ranch Hand
Joined: Feb 16, 2008
Posts: 138
|
|
i am new in programing
anybody explain difference between call by value and call by reference with example ?
please also explain this program
[HENRY: Added code tags]
|
 |
Himanshu Kansal
Ranch Hand
Joined: Jul 05, 2009
Posts: 257
|
|
Hello,
please post the code in proper tags.
Also, the code is not complete. Value class is missing
Regards
|
Experience and talent are independent of age
|
 |
vineet walia
Ranch Hand
Joined: Feb 16, 2008
Posts: 138
|
|
Himanshu Kansal wrote:Hello,
please post the code in proper tags.
Also, the code is not complete. Value class is missing
Regards
its working and its output is 15 0
20
|
 |
Himanshu Kansal
Ranch Hand
Joined: Jul 05, 2009
Posts: 257
|
|
Once you edited to put the Class Value's definition, you could have put in the CODE tags too.
|
 |
Himanshu Kansal
Ranch Hand
Joined: Jul 05, 2009
Posts: 257
|
|
Here is a line to clear all misunderstandings - Java is strictly Pass-by-Value.
If at some point you feel that a pass by reference has occured as in your code at second(v,i), you actually are passing the reference itself as a value. Hence any changes made to the reference are reflected in the actual arg.
I hope that you are clear that when we say, "a" is only a reference that points to the object. Therefore, when you pass this "a" to a method, you actually pass a reference pointing to that object; which in turn is a pass by value because the reference is COPIED in the formal argument
Regards
|
 |
Mo Jay
Ranch Hand
Joined: Feb 16, 2009
Posts: 83
|
|
Also vineet walia , you need to quote your sources and say where you got this code from. This is one of the requirements when posting any piece of code here.
As of the output of the program, it is strait forward and I think that the guys (Himanshu) before me have done a good job describing the difference (if there is any) between pass-by-value and pass-by-reference.
|
 |
 |
|
|
subject: please explain
|
|
|