请问String是传值的吗 Strings are constant; their values cannot be changed after they are created. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 String 是 immutable的。把你的代码贴出来。 public int MyEncrypt(String str,int num){ str="ok";}main(){ String temp = "mystr"; MyEncrypt(temp); System.out.println(temp);//temp还是mystr} 你这什么程序啊,错误多多答案是mystrString是类,传地址的public class SYH{ public void MyEncrypt(String str) { str="ok"; } public static void main(String[] args) { String temp = "mystr"; new SYH().MyEncrypt(temp); System.out.println(temp);//temp还是mystr }} Java的参数传递其实是“值的副本”的传递刚才我没有说清楚你看看我的这个帖子吧http://www.csdn.net/expert/topic/507/507466.xml?temp=.5703699 你好好看看那个帖子吧,很有帮助的要改变引用所指的值,如下:public class SYH{ String s="111"; public static void main(String[] args) { SYH syh=new SYH(); syh.change("222"); System.out.println(syh.s); } public void change(String str) { this.s=str; } } 那你需要把这个字符串写成这个类中的一个域,然后用set方法来改变它! 是传地址,但String的内容不能修改! 用StringBuffer修改后,返回String即可! 用StringBuffer修改后,返回String即可! http://java.sun.com/j2se/1.4/docs/api/java/lang/StringBuffer.html 正则表达式split()迷惑...求解惑! java的异常处理 awt求助帖 哪位知道怎么在JAVA中实现打印功能?在线等待,急! 关于java虚拟机,再问! 请问谁有发送手机短信模块,可以考虑购买! 一个类的一个构造函数可否调用这个类的另一个构造函数? 谁用过QueryString,需要加入什么包???? 在vj++中如何加载一张图片? 各位兄弟帮帮忙,谁能给我的画板程序一点提示 java桌面程序想要上传文件如何实现呢? 这个错误是什么意思:java.sql.SQLException: ORA-01008: 并非所有变量都已关联;
public int MyEncrypt(String str,int num){
str="ok";
}
main(){
String temp = "mystr";
MyEncrypt(temp);
System.out.println(temp);//temp还是mystr
}
{
public void MyEncrypt(String str)
{
str="ok";
}
public static void main(String[] args)
{
String temp = "mystr";
new SYH().MyEncrypt(temp);
System.out.println(temp);//temp还是mystr
}
}
{
String s="111";
public static void main(String[] args)
{
SYH syh=new SYH();
syh.change("222"); System.out.println(syh.s);
}
public void change(String str)
{
this.s=str;
}
}