| 太谢谢你啦。:)
 我就是想通过地址改变,发现不行,除非在函数中传来的 句柄+[下标]改变  不能
 
 最后我用ArrayList集合试了这个可以,复制代码<b>fun(String s){
  String s2="xinde ";  
    s=s2;  //这好像是s有指向了新的对象,原来的就丢失了
}</b>
 复制代码import java.util.*;
import java.util.ArrayList;
import java.util.ListIterator;
public class Text2 {  
 static void  fun(ArrayList<font color="Red"><Character> a</font>){
              <font color="Red">ListIterator it1=a.listIterator();</font>
              char []c={ '1','2' ,'3','4' ,'5','6','7' };
              for(char s:c){
                     if(it1.hasNext()){
                             it1.next();
                             <font color="DarkOrchid">it1.set(new Character(s));</font>
                             
                     } 
                     else{break;}
              }
      }
 public static void main(String[]args){
                ArrayList<Character> a=new ArrayList<Character>();
                
                char []c={ 'A','B' ,'C','D' ,'E' }; 
                for(char v:c){
                        a.add(new Character(v));
                }
                <font color="Red">fun(a);</font>
                System.out.println(a);
        }
     }
其他数组传来不能用,比如下面的
 
 发现复制代码<b>void fun(int a []){
   int []a2={1,2,3,4,5,6};
   a=a2;
}</b>
1.C语言                                                                                             2java
 #include <stdio.h>                                                                         class java{
 void fun(char p[] ){//char *p                                                         void fun(  char [] p ){
 char code[]={'4','5','6','7'};                                                            char []code={'4','5','6','7'};
 p=code//此时p所指的对象本身发生了变化                                     p=code;   ///应该只是对象句柄转移
 }                //如果参数改为char p[4]是传值像java的克隆                   }                   //不会干扰传来的a数组
 void main(){                                                                                   public static void main(String[]args){
 char a[]={'1','2','3','4'};                                                                  char [] a={'1','2','3','4'};
 fun(  a );     printf("%s",a)   // 输出4567                                   fun( a );  System.out.println(new String(a));  //输出1234
 }                                                                                                    }  }//System.out.println(a);将输出乱码地址
 
 本来还想到通过 System类的arraycopy静态函数用于数组拷贝但还是不行
 
 但是如果通过您说的通过返回值来改变复制代码import java.util.*;
public class Text2 {
        <b>static void fun(ch<font color="DarkRed">ar[] s)</font>{
                <font color="Red">char []b="AAA"</font>.toCharArray();
               <font color="Red">System.arraycopy(s, 0,b ,0, 2); </font>
                }
        public static void main(String[]args){
               <font color="Blue">char []s="QQQ".toCharArray();</font>
                <font color="DarkRed">fun(s);</font>
               <font color="Red">System.out.println(new String(s));</font>
        }
}
结果却是
QQQ</b>
处理一个参数可以要是想处理多个参数就不能通过一个返回值来改变了 比如复制代码<b>  public static void main(String[] args)
        {
                String s = "";
                <font color="DarkOrchid">s= ChangeStrTo();</font>
                System.out.printl<font color="DarkOrchid">n(s);</font>
        }
        public static<font color="DarkOrchid"> String</font> ChangeStrTo()
        {
                String sTemp = new String("Hello!");
                return sTemp;
        }</b>
____fun(int [ ] a ,char [ ] c, String s){
 ...
 }
 最后您有帮我找到了另一个方法就是
 
 谢谢你复制代码<font color="DarkRed"><b>通过StringBuilder来改变内容,见下:
public class StringFunc {
        public static void main(String[] args)
        {
                StringBuilder s = new StringBuilder();
                ChangeStrTo(s);
                System.out.println(s);
        }
        public static void ChangeStrTo(StringBuilder strBuilder)
        {
                strBuilder.append("Hello!");
        }
}
</b></font>
 
 
 
 
 
 |