Strings are constant; their values cannot be changed after they are created.

解决方案 »

  1.   

    String 是 immutable的。把你的代码贴出来。
      

  2.   


    public int MyEncrypt(String str,int num){
        str="ok";
    }
    main(){
        String temp = "mystr";
        MyEncrypt(temp);
        System.out.println(temp);//temp还是mystr
    }
      

  3.   

    你这什么程序啊,错误多多答案是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
      }
    }
      

  4.   

    Java的参数传递其实是“值的副本”的传递刚才我没有说清楚你看看我的这个帖子吧http://www.csdn.net/expert/topic/507/507466.xml?temp=.5703699
      

  5.   

    你好好看看那个帖子吧,很有帮助的要改变引用所指的值,如下: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;
      }
      
    }
      

  6.   

    那你需要把这个字符串写成这个类中的一个域,然后用set方法来改变它!
      

  7.   

    是传地址,但String的内容不能修改!
      

  8.   

    用StringBuffer修改后,返回String即可!
      

  9.   

    用StringBuffer修改后,返回String即可!
      

  10.   

    http://java.sun.com/j2se/1.4/docs/api/java/lang/StringBuffer.html