Converting a TreeSet to ArrayList?

前端 未结 3 1678
花落未央
花落未央 2020-12-17 08:52

I have a TreeSet which contains > 100k objects. I have another method which requires ArrayList as an param.

Is there any way I can accomplish this without iterating

3条回答
  •  庸人自扰
    2020-12-17 09:14

    ArrayList has a convenience method addAll that fits the bill nicely:

    final Set set = ...
    List list = new ArrayList(someBigNum);
    list.addAll(set);
    
        

    提交回复
    热议问题