-4

I would like to make a sum of 2 arrays. I don't know where is the mistake. here is the code:

    public static int[] Arr(int a[], int b[]) {
    System.out.println(a[] + b[]);
    return a[] + b[];
}
dreamcrash
  • 47,137
  • 25
  • 94
  • 117
lezio
  • 1

1 Answers1

0

I think he wants something like this :

public static int[] Arr(int a[], int b[]) {

    int[] sum = new int[a.length + b.length];

    for (int i = 0; i<a.length;i++) {
        sum[i] = a[i];
    }
    for (int i = a.length; i<a.length + b.length;i++) {
        sum[i] = b[i-a.length];
    }
    System.out.println(Arrays.toString(sum));
    return sum;
}
AirlineDog
  • 520
  • 8
  • 21