array

public class array01 {
public static void main(String[] args) {
int[]arrays ={12,23,433,545};//定义一个数组
int[] reverse = reverse(arrays);//重新定义一个新的反转数组

for (int i = 0; i < reverse.length; i++) {
System.out.println(reverse[i] + " ");
}
}
//反转数组
public static int[] reverse(int[] arrays) {
int[] result = new int[arrays.length];
//反转的操作
for (int i = 0, j=result.length-1;i < arrays.length ; i++,j--) {
result[j]=arrays[i];
}
return result;
}
}

array

上一篇:POJCrossing River


下一篇:5.字符串、列表、元祖常用操作