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 ?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
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?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.
Last edited by Norm; November 6th, 2011 at 04:00 PM.
int add [] = p[i] + q[j];
What does that line do? Think about it carefully and be very exact.
Improving the world one idiot at a time!