How do I join two lists in Java?

后端 未结 30 2063
旧巷少年郎
旧巷少年郎 2020-11-22 14:36

Conditions: do not modifiy the original lists; JDK only, no external libraries. Bonus points for a one-liner or a JDK 1.3 version.

Is there a simpler way than:

30条回答
  •  旧时难觅i
    2020-11-22 15:29

    Found this question looking to concatenate arbitrary amount of lists, not minding external libraries. So, perhaps it will help someone else:

    com.google.common.collect.Iterables#concat()
    

    Useful if you want to apply the same logic to a number of different collections in one for().

提交回复
热议问题