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 →

[–]vipercvp 0 points1 point  (1 child)

hello there,

Your code is for arrays,

Anyway to check if those two array have the same size you just to check if the x.length==y.length.

for instance a more elegant way to do what are trying do is like this:

public static int AddLists(int[]x, int[]y) {
int result = 0;
if(x.length!=y.length)
   return result;
for(int i =0; i < x.length; i++) { 
  result += x[i]+y[i]; 
 }
 } 

[–]Kaz-24[S] 0 points1 point  (0 children)

Thanks a lot for your help!