Link to home
Start Free TrialLog in
Avatar of ScottRogersGC
ScottRogersGC

asked on

How do I concatenate object arrays on the fly?

I have a method that returns an array of objects, this method is called for each item in another array from within a for-loop. I wish to add the new array returned by each of these calls to a single array.
ASKER CERTIFIED SOLUTION
Avatar of ellandrd
ellandrd
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mick Barry
you need to concatenate the two arrays

http://www.objects.com.au/java/qa/1839197685.html
thank you

ellandrd
Avatar of mnrz
mnrz

what you mean "new array" if you want the returned array be separated from the original you may clone the returned array:

for(...){
      Object[] myNewArray = returenedArray.clone();
}

or use System.arraycopy() to copy to new array object

What it not good enough for a grade A?

ellandrd
Avatar of ScottRogersGC

ASKER

can't go round handing out grade A's every day :-)
Your a Premium Service Member like me - isn't points unlimited? so who cares?

;-)
ellandrd,
your solution is not efficient

the objects' post is fundamental way of resolving the problem so he is eligible to achieve the points
System.arraycopy