
高手来看看这个例子!!
publicclassExample{Stringstr=newString("good");char[]ch={'a','b','c'};publicstaticvoi...
public class Example{
String str=new String("good");
char[]ch={'a','b','c'};
public static void main(String args[]){
Example ex=new Example();
ex.change(ex.str,ex.ch);
System.out.print(ex.str+" and ");
Sytem.out.print(ex.ch);
}
public void change(String str,char ch[]){
str="test ok";
ch[0]='g';
}
}
请问这个程序为什么输出good and abc??为什么输出这个结果而不是test ok and g
是good and gbc 不好意思 我打错了 展开
String str=new String("good");
char[]ch={'a','b','c'};
public static void main(String args[]){
Example ex=new Example();
ex.change(ex.str,ex.ch);
System.out.print(ex.str+" and ");
Sytem.out.print(ex.ch);
}
public void change(String str,char ch[]){
str="test ok";
ch[0]='g';
}
}
请问这个程序为什么输出good and abc??为什么输出这个结果而不是test ok and g
是good and gbc 不好意思 我打错了 展开
6个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询