Possible Duplicate:
Java pass by reference issue
In my codes below, methodA
will be called, which then delegates a call to methodB
, in doing so, methodB
assigns the input parameter with String literal "bbb", however, back at methodA
, the string literal was not there, which section of the JLS defines this behavior?
package sg.java.test2;
public class TestApple {
public static void main(String args[]){
methodA();
}
public static void methodA(){
String a = null;
methodB(a);
System.out.println(a);
}
public static void methodB(String a){
a = new String("bbb");
}
}