ADD TWO ELEMENTS IN AN ARRAY code example
Example: addition of two arrays
int[] a = {10, 20 30, 40}; int[] b = {25, 50, 75, 100, 125}; int[] sum = new int[b.length]; for (int i = 0; i <= b.length; i++){ sum[i] = 0; /*initialize each of the sum values as zeroes, because that's what we usually start with*/ if (i > b.length){ /*if one array is longer than the other, just add zero the remaining elements in the largest array*/ sum[i] = b[i] + 0; else{ sum[i] = a[i] + b[i]; } }