Why does the following code print "1234" rather than "welcome"?I think that String is not a primitive variable,it is an object.So the function "changeStr" get the reference of "str".But the fact is seem like "changeStr" get a copy of the str.Why?
public class Test1 {
public static void changeStr(String str){
str="welcome";
}
public static void main(String[] args) {
String str="1234";
changeStr(str);
System.out.println(str);
}
}