对于下列代码:publicclassExample{Stringstr=newString("hello");charch[]={'d','b','c'};publicstaticvoidmain(Stringargs[]){Exampleex=newExample();ex.change(ex.str,ex.ch); System.out.println(ex.str+"and"+ex.ch[0]); } publicvoidchange(Stringstr,charch[]){str="world";ch[0]='a';}}输出结果是:
对于下列代码:publicclassExample{Stringstr=newString("hello");charch[]={'d','b','c'};publicstaticvoidmain(Stringargs[]){Exampleex=newExample();ex.change(ex.str,ex.ch); System.out.println(ex.str+"and"+ex.ch[0]); } publicvoidchange(Stringstr,charch[]){str="world";ch[0]='a';}}输出结果是:
1