public class Test{
static int[] concatenate (int[] a, int[] b){
int[] newArr = new int[a.length + b.length];
for (int i = 0; i < a.length; i++){
newArr[i] = a[i];
}
for (int i = 0; i < b.length; i++){
newArr[i+a.length]= b[i];
}
return newArr;
}
public static void main(String[] args){
int[] a = {1,2,3};
int[] b = {4,5,6};
System.out.println(concatenate(a,b));
}
}
当我运行代码时,这就是我得到的答案:
[I @ 15db9742
我猜这与代码的public static void main(String [] args)部分有关,因为第一个类正在返回一个数组?