• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

array

 
Sanjay Saxena
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic