public static int[] arrayAdd(int[] p, int[] q) {
for (int i = 0; i < p.length; i++) {
for (int j = 0; j < q.length; j++) {
int add [] = p[i] + q[j];
}
}
return add;
}
Hi, i dont know, how to add two simple data array....can you help mi please ?
Printable View
public static int[] arrayAdd(int[] p, int[] q) {
for (int i = 0; i < p.length; i++) {
for (int j = 0; j < q.length; j++) {
int add [] = p[i] + q[j];
}
}
return add;
}
Hi, i dont know, how to add two simple data array....can you help mi please ?
What does the posted code do that is wrong?
Can you explain what your problem is? Do you get errors?
Please post the full text of the error messages.
My problem is, that it doesnt work...i just want add two arrays and save it to the new array. And i dont know how i can use this function with the specific numbers ?
What does the code do when you execute it?Quote:
it doesnt work.
Have you tried writing down on a piece of paper what you want to happen for each element in the three arrays to see how to use the for loop and its index?
Write one expression on each line showing the array references and the values of the array indexes.
int add [] = p[i] + q[j];
What does that line do? Think about it carefully and be very exact.