Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   How to combine 2 int Array into ONE int Array ? (http://www.velocityreviews.com/forums/t125774-how-to-combine-2-int-array-into-one-int-array.html)

S300 08-19-2003 04:03 AM

How to combine 2 int Array into ONE int Array ?
 
How to combine 2 int Array into ONE int Array ?


thanks



Dario 08-19-2003 07:34 AM

Re: How to combine 2 int Array into ONE int Array ?
 
S300 wrote:

> 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;
}
}


Roedy Green 08-19-2003 08:34 AM

Re: How to combine 2 int Array into ONE int Array ?
 
On Tue, 19 Aug 2003 12:03:45 +0800, "S300" <s300@samsung.com> wrote or
quoted :

>How to combine 2 int Array into ONE int Array ?


allocate a new array and use a couple of for loops or a couple of
arraycopys.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.

Tim Tyler 08-19-2003 02:35 PM

Re: How to combine 2 int Array into ONE int Array ?
 
biro <me@privacy.net> wrote:

: 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.
--
__________
|im |yler http://timtyler.org/ tim@tt1.org

Roedy Green 08-19-2003 07:04 PM

Re: How to combine 2 int Array into ONE int Array ?
 
On Tue, 19 Aug 2003 12:06:03 +0100, "biro" <me@privacy.net> wrote or
quoted :

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



historical. Arrays was not invented until around Java 1.2
--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.


All times are GMT. The time now is 08:22 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.