Can I change String object's value passed to my method?
问题 I found the following question Is Java "pass-by-reference" or "pass-by-value"?. I read almost all of it, but could not find out yet what should I do if I want the foo(-) method, to change my String 's value ? (maybe or not reference too, it doesn't matter to me). void foo(String errorText){ errorText="bla bla"; } int main(){ String error="initial"; foo(error); System.out.println(error); } I want to see bla bla on the console. Is it possible? 回答1: You can't change the value of errorText in foo