search

Home  >  Q&A  >  body text

java - 怎么把四个list集合整合到一个集合中。

把四个集合里面的内容都存入一个集合(最后的集合已经有了四个集合的set,get方法了)

怎么四变一

高洛峰高洛峰2821 days ago1122

reply all(6)I'll reply

  • ringa_lee

    ringa_lee2017-04-18 09:58:54

    addAll() doesn’t work...

    reply
    0
  • 高洛峰

    高洛峰2017-04-18 09:58:54

    Are the generics of these four collections the same?

    reply
    0
  • 怪我咯

    怪我咯2017-04-18 09:58:54

    If the generics are consistent, use the addall() method to add it to a new List. If you need to remove duplicates, use Set’s addall ()

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-18 09:58:54

    Write a wrapper collection class and delegate to the corresponding sub-collection as needed.
    Usually just inherit AbstractList, and the constructor puts four or more sub-collections in.

    reply
    0
  • 迷茫

    迷茫2017-04-18 09:58:54

    It is recommended that you go to Google's guava toolkit... There are ready-made ones...

    reply
    0
  • 阿神

    阿神2017-04-18 09:58:54

    addAll() is enough

    reply
    0
  • Cancelreply