How to combine 2 int Array into ONE int Array ?

D

Dario

S300 said:
How to combine 2 int Array into ONE int Array ?

class A49 {
public static int[] getONE(int[] arg1, int[] arg2) {
int[] result = new int[arg1.length+arg2.length];
System.arraycopy(arg1, 0, result, 0, arg1.length);
System.arraycopy(arg2, 0, result, arg1.length, arg2.length);
return result;
}
}
 
T

Tim Tyler

: int[] newarray = new int[array1.length + array2.length];

: And then use System.arraycopy to populate it.

: Why it's in System and not Arrays I don't know.

"Arrays" didn't exist at the time. That's why.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top