File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "array" Watch "array" New topic
Author

array

Sanjay Saxena
Ranch Hand

Joined: Dec 12, 2001
Posts: 81
I have a string array SA1 = {"AAA", "BBB", "CCC"};
and another array SA2 = {"DDD", "EEE", "FFF"};
Now I want to concatenate SA1 and SA2 to get a third array SA3 = {"AAA", "BBB", "CCC", "DDD", "EEE", "FFF"};
Can anybody tell me how to do this?
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
You'll need to declare a third array that is the length of the sum of the lengths of the original two arrays. Then, you could write a for-loop or two and copy each component from the two source arrays into the new destination array, but it would probably be easier and faster to make use of System.arraycopy.
Any luck?


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: array
 
Similar Threads
Priority Queue Ordering Question
How to split a string by the whitespace but ignoring '\n'?
Preceding siblings
Report in JSP
help - what's the difference: axis following and axis following-sibling?