public class test{
public static void function(String[] array){
for(int i = 0; i < array.length; i++){
System.out.println(array[i]);
}
}

public static void main(String args[]){
String[] strArray = {"one","two","three","four","five","six"};

function(strArray);
}
}

解决方案 »

  1.   

    public class BbsTest1
    {
      public static void exchange(String a1,String a2)
      {
             String temp=a1;
             a1=a2;
              a2=temp;
    }
    public static void main(String []args)
    {
    String[] str ={"one","two","three","four","five","six"}; exchange(str[1],str[2]);                for(int i=0;i<str.length;i++)
                     System.out.print(str[i]+"  ");
    }
    }数组元素并没有被交换,所以不是直接传数组,而是copy引用~