I am a little confuse , let me re-say it "In Java every function call is call by value in case of objects it will be call by value of the reference variables " . Now in the code below swap is working as expected (o/p is JavaRanch), but why does add function is changing the state of the object referenced by aL the o/p should  rather than [Hi I am ArrayList] .
Please explain , Thanx in advance
Jeroen T Wenting
posted 11 years ago
You're changing the state of that to which the reference refers (the content of the list). That's quite possible, as you're not changing the reference itself (you're not replacing the list with another one).