java中方法对于String类型全部变量的操作
publicclassTest1{Stringstr=newString("jursoft");Stringstr1=("jursoft");Stringstr2=new...
public class Test1 {
String str = new String("jursoft");
String str1 = ("jursoft");
String str2 = new String("jursoft");
char[] ch = {'a','b','c'};
public static void main(String[] args){
int num = 2014;
Test1 t = new Test1();
num = t.change(t.str, t.ch, num);
System.out.println(t.str + " " + num + " " + new String(t.ch) + " " + t.str1 + " " + t.str2);
}
private int change(String str,char[] ch,int num){
str = "com";
str1 = "com";
str2 = new String("com");
ch[2] = 'd';
num += 1;
return num;
}
}
输出结果为str=jursoft str1 = com str2 = com
想请教一下关于为何出现这种结果? 展开
String str = new String("jursoft");
String str1 = ("jursoft");
String str2 = new String("jursoft");
char[] ch = {'a','b','c'};
public static void main(String[] args){
int num = 2014;
Test1 t = new Test1();
num = t.change(t.str, t.ch, num);
System.out.println(t.str + " " + num + " " + new String(t.ch) + " " + t.str1 + " " + t.str2);
}
private int change(String str,char[] ch,int num){
str = "com";
str1 = "com";
str2 = new String("com");
ch[2] = 'd';
num += 1;
return num;
}
}
输出结果为str=jursoft str1 = com str2 = com
想请教一下关于为何出现这种结果? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询