Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How to combine 2 int Array into ONE int Array ?

Reply
Thread Tools

How to combine 2 int Array into ONE int Array ?

 
 
S300
Guest
Posts: n/a
 
      08-19-2003
How to combine 2 int Array into ONE int Array ?


thanks


 
Reply With Quote
 
 
 
 
Dario
Guest
Posts: n/a
 
      08-19-2003
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;
}
}

 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      08-19-2003
On Tue, 19 Aug 2003 12:03:45 +0800, "S300" <(E-Mail Removed)> 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.
 
Reply With Quote
 
Tim Tyler
Guest
Posts: n/a
 
      08-19-2003
biro <(E-Mail Removed)> 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/ http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      08-19-2003
On Tue, 19 Aug 2003 12:06:03 +0100, "biro" <(E-Mail Removed)> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to combine 2 unsigned short into a unsigned int? fancyerii Java 21 11-05-2007 09:33 PM
Combine 2 or more XMLDocuments into one... David Lozzi ASP .Net 1 10-19-2005 02:02 AM
How to combine tree controls into one ad ASP .Net 1 07-14-2005 09:29 AM
int main(int argc, char *argv[] ) vs int main(int argc, char **argv ) Hal Styli C Programming 14 01-20-2004 10:00 PM
dirty stuff: f(int,int) cast to f(struct{int,int}) Schnoffos C Programming 2 06-27-2003 03:13 AM



Advertisments