JAVA 陣列在函數間傳遞(JAVA陣列傳遞預設是傳參考)
JAVA 陣列在函數間傳遞(JAVA陣列傳遞預設是傳參考)
public class ArrayPrint {
public static void print(int x[])
{
for(int i=0;i<x.length;i++)
{
System.out.print(x[i]+”,”);
}
System.out.println(“”);
}
public static void main(String args[])
{
int a[]={1,2,3,4,5,6,7,8,9};
int b[]={9,8,7,6,5,4,3,2,1};
print(a);
print(b);
}
}