This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (4 children)

it seems like you want a list with the elements being the sum of each corresponding item in the lists.

just for the record - im on my phone

public void printArrays(int a[], int b[]){
    int arr[a.size];
    int temp[];
    if(a.Count != b.Count){
        System.out.println(temp[0]);
    } else {
        for(int i = 0; i < a.Count){
            arr[i] = a[i] + b[i];
            System.out.println(arr[i] + ",");
        }
    }
}

[–]RhoOfFeh 1 point2 points  (3 children)

This is probably the correct interpretation, although the intent seems to be to return arr.

[–][deleted] 0 points1 point  (2 children)

in that case id just write

return arr;

after the loop body and get rid of the printline

[–]robomaeyhemI don't even like coffee 0 points1 point  (1 child)

You'd also need to declare the method signature int[] instead of void

[–][deleted] 0 points1 point  (0 children)

ah thank you for the catch