java - How to add to an arraylist without creating an embedded array -


i know arraylist has .add() method, reason, whenever add prexisting arraylist, end getting embedded array.... have method returns objectinputstream, 1 or more objects , depending on conditional, wanted add , present user, however, it's embedding objectinputstream array.

for example:

1. [item1] 2. [item1, item2] 3. [[item1, item2], item3] 4. [[[item1, item2], item3], item4] 

it keeps going this. i'd prefer if more this:

[item1, item2, item3, item4] 

the issue is, using arraylist.add() method instead of arraylist.addall() method. add() method adds object passed on list, addall takes collection, , adds each element in collection list- want.


another issue note is, not using generics. have avoided error completely.

i have sample code convenience in online java compiler ide.

as side note, in future when asking programming questions, embed small sample of relevant code in online ide codiva or ideone, want answer.


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -