2012年5月31日 星期四

Java Basic(32)-Arrays in Methods


class apples{
public static void main(String args[]){
int bucky[]={3,4,5,6,7};
change(bucky); 將列陣放入change()
for(int y:bucky)
System.out.println(y);
}
public static void change(int x[]){
for(int counter=0;counter<x.length;counter++)
x[counter]+=5;
}
}


So the program will see that:
8
9
10
11
12

沒有留言:

張貼留言