+ 2

How 6 is printed even though x is a static member

Static members in java https://code.sololearn.com/ce4G0x2FIfB2/?ref=app

4th Jun 2021, 12:02 AM
alagammai uma
alagammai uma - avatar
2 Answers
+ 4
Because at the end of the m() method the value of a is returned. a is the same value the is passed to the m() method. Even though the value of x is changed within the m(), it is then set to the value of a back in main() which is 6.
4th Jun 2021, 12:29 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
ChaoticDawg thank you
4th Jun 2021, 12:34 AM
alagammai uma
alagammai uma - avatar