SCJP 6 [86%], OCPWCD [84%], OCEJPAD [83%]
If you find any post useful, click the "plus one" sign on the right
Prasad Khakar wrote:...from this question I also came to know that when we pass with increment , the increment happens only after all the method execution has completed
SCJP 6
SCJP 6 [86%], OCPWCD [84%], OCEJPAD [83%]
If you find any post useful, click the "plus one" sign on the right
isn't it that we are passing the COPY to the method
how come the original variable i is changing even if we are passing a copy to the variable?
or in this case as we are passing it with the increment operator, copy is not passed any original variable is passed?
what is that?
Ritesh Pareek wrote:
# m(i++); // Passing variable to m() and getting back over here and increment
SCJP 6 [86%], OCPWCD [84%], OCEJPAD [83%]
If you find any post useful, click the "plus one" sign on the right
SCJP 6 [86%], OCPWCD [84%], OCEJPAD [83%]
If you find any post useful, click the "plus one" sign on the right
In your code,You post increment the value which is in the main not in the method m().So only the original value get changed not a copy.
But in this coe the value which is in the method m() only post incremented so you got the answer like 2,1,2.
Cheers Munees
My Blog
Something must be done about this. Let's start by reading this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|