• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Merge array's in java?

 
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI all,
I am stuck in a situation where i need to merge the contents of two long[].
Heres the example for my requirement

I know the routine way of running for loops to copy the contents from one array to other...
IS THERE ANY OTHER EFFICIENT WAY OF DOING THIS.
Regards
Reshma
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Believe it or not System has a method to help you with that. arraycopy (Yes, naming convention doesn't follow Sun's standard imagine that :roll: )
:roll:
[ August 27, 2003: Message edited by: Carl Trusiak ]
 
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check into System.arrayCopy()
You should be able to create a third array with a length equal to the sum of the other two. Then just use this method to place the elements from the first two into the third array.
hth
-EDIT----------------------------
DOH! Carl beat me to it...
---------------------------------
[ August 27, 2003: Message edited by: Chris Shepherd ]
 
Reshma Shanbhag
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Chris .
Thanks a ton for the help, it was extremely helpful to me. For a while i was in java.util park looking for this functionality :roll:
Reshma
[ August 27, 2003: Message edited by: Reshma Pai ]
reply
    Bookmark Topic Watch Topic
  • New Topic