1、public class Test {
public static void changeStr(String str){
str="welcome";
}
public static void main(String[] args) {
String str="1234";
changeStr(str);
System.out.println(str);
}
}
Please write the output result :看了很多人的回答,说了一大堆。其实,这题就考1点。就是 changeStr方法里str="welcome";  到底是改变原有的对象(mian方法里str传给它的),还是产生新的对象。大家都知道  str="welcome" 就相当于 str=new String("welcome")所以main方法的 str当然还等于1234咯。就这么简单啊,别想复杂了。还有就是main方法里的str和changeStr方法里的str那个是2个不同的变量哦。这下清楚了吧!怎么,还不明白那我也没招了~~哈哈^____^