The answer is what's being changed inside the method is only a local variable (i.e., a copy of the variable passed in). Changing the local variable's value does not affect the value of the variable that was passed to the method.
Originally posted by PRATIK LOHIA: primitive datatypes such as int, boolean, double, long etc. are all pass by values during method calls. Objects except Strings are pass by reference. Hence the value of j does not change
There is absolutely nothing whatsoever that differs between how Strings are passed as parameters and how any other kind of object is passed. Strings receive no special treatment of any kind.
Further (as has already been stated above) everything is passed by value, but in the case of objects, the value that is passed is a pointer (a reference) to the object, since that is what variables of reference type contain.
If you read the two stories I link to in my first post, you'll get a good explanation of this.
subject: Why primitive arguement's value won't be changed even it's changed in method