Forums Register Login

How can I unite two arrays to one array?

+Pie Number of slices to send: Send
Hello everyone,I want to know how many methods can resolve it.
I try to use loop to do it,but I think it is not a good thing.
+Pie Number of slices to send: Send
I implement it as following:

so I got it.but I donnt know if I should do so.
[ July 28, 2003: Message edited by: qingwu wang ]
+Pie Number of slices to send: Send
qingwu,
I think you can use arraycopy() method from System class to achieve it.
+Pie Number of slices to send: Send
You could write a merge method ( or I can ):

or you could utilize the List interface:

Hope that helps,
Jamie
[ July 29, 2003: Message edited by: Jamie Robertson ]
+Pie Number of slices to send: Send
There's also this operation:
list1.addAll(list2);
+Pie Number of slices to send: Send
Thanks chi,Jamie,Ron...
+Pie Number of slices to send: Send
A little simpler, but not as efficient:

Joe
+Pie Number of slices to send: Send
Object[] obj3a = new Object[obj1.length + obj2.length];
System.arraycopy(obj1, 0, obj3a, 0, obj1.length);
System.arraycopy(obj2, 0, obj3a, obj1.length, obj2.length);
WARNING! Do not activate jet boots indoors or you will see a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1548 times.
Similar Threads
Assertion Doubt.
I've bought Sybex Java 2 Certification Virtual Trainer
ConnectionFactory lookup returns null
Hide Standart Buttons in Taskbar
Increase memory for tomcat
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 16:30:09.