String取值

cpisapple cpisapple 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
public class Example{
String str=new String("hello");
char ch[]={'d','b','c'};
public static void main(String args[]){
Example ex=new Example();
ex.change(ex.str,ex.ch);
System.out.println(ex.str+"and"+ex.ch[0]);
}
public void change(String str,char ch[]){
str ="world";
ch[0]= 'a';
}
}

结果是helloanda
为什么不是worldanda ? 难道不能通过引用改变字符窜的值吗
...全文

相关推荐

评论 20
收藏 已收藏
分享
返回顶部
cpisapple
Java SE 62,620 成员 307,251 内容