import java.util.Arrays;
public class Test {
//把数组中每个数据扩大2倍
public static int[] func1(int[] array) {
int[] ret = new int[array.length];
for (int i = 0; i < array.length; i++) {
ret[i] = array[i] * 2;
}
return ret;
}
public static void main(String[] args) {
int[] array = {1, 2, 3, 4, 5};
//int[] array2 =null;
//System.out.println(array2.length);
//System.out.println(array2[0]);
int[] tmp = func1(array);
System.out.println(Arrays.toString(array));
System.out.println(Arrays.toString(tmp));
}
}
//把数组中的每个数据扩大两倍--数组本身扩大2倍
public static void func2(int[] array) {
for (int i = 0; i < array.length; i++) {
array[i] = array[i] * 2;
}
}
public static void main(String[] args) {
int[] array = {1, 2, 3, 4, 5};
System.out.println(Arrays.toString(array));
func2(array);
System.out.println(Arrays.toString(array));
}