Best way to get value from Collection by index

前端 未结 10 1540
旧时难觅i
旧时难觅i 2020-12-05 17:08

What is the best way to get value from java.util.Collection by index?

10条回答
  •  无人及你
    2020-12-05 17:43

    You must either wrap your collection in a list (new ArrayList(c)) or use c.toArray() since Collections have no notion of "index" or "order".

提交回复
热议问题