adding two arraylists into one

前端 未结 1 1016
执笔经年
执笔经年 2021-02-14 03:55

I want to check branchList whether has same element or not, if same put branchList and tglList element separate arraylist and put that arraylist into another arraylist,

相关标签:
1条回答
  • 2021-02-14 04:28

    I didn't thoroughly read through your code (and I don't quite get what you're asking for), but if you want to merge (add the elements of) branchList and tglList to TglList1, try this:

    TglList1.addAll(branchList);
    TglList1.addAll(tglList);
    

    After that, TglList1 should contain all elements of both lists. If you need the list to be sorted, you might want to call Collections.sort(TglList1) afterwards (just note that sorting strings might place "100" before "2", due to "1" being lexically smaller than "2").

    0 讨论(0)
提交回复
热议问题