Topic: 为什么会出现这样的结果?? |
Print this page |
1.为什么会出现这样的结果?? | Copy to clipboard |
Posted by: freshman0216 Posted on: 2004-11-20 12:11 public class Test5{ public static void main(String[] args){ String s=new String("World"); char[] c={'a','s','d'}; change(s,c); System.out.print(s+" and "); for(int i=0;i<c.length;++i){ System.out.print(c[i]); } } public static void change(String s,char[] c){ s="chaged"; c[0]='c'; c[1]='v'; c[2]='v'; } } 结果是:World and cvv 数组是怎样传递参数的?成员变量和方法参数变量有什么不同?? |
2.Re:为什么会出现这样的结果?? [Re: freshman0216] | Copy to clipboard |
Posted by: wuyongjin Posted on: 2004-11-21 16:10 还是好好把书看看吧 很基础的知识啊 public static void change(String s,char[] c){ s="chaged"; c[0]='c'; c[1]='v'; c[2]='v'; } 中的s是局部变量 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |