Hey guys,
The following is my code:
public class OneB { /** * @param args */ public static int[] sumDiffs(int[]a, int[]b){ int[]sum=new int[a.length]; for(int i=0;i<a.length;i++){ if(a[i]==b[i]){ sum[i]=a[i]; }else{ sum[i]=a[i]+b[i]; } } return sum; } public static void main(String[] args) { System.out.println(sumDiffs(new int[] {1,2,3,4,5},new int[]{1,2,3,4,5})); } }
As you can see from the above code that i have 2 arrays and have to return a new array. For each position at a and b, if the elements at i differ, then the new array should be the sum of the two, otherwise it should be the value shared between the two arrays. The arrays are of the same length.
But when i try to run the code on eclipse, i get the following error:
[I@f7e6a96
whereas it should behave as:
sumDiffs(new int[] {1,2,3,4,5},new int[]{1,2,3,4,5})-> {1,2,3,4,5}
Anyone knows where i've gone wrong?