How to lowercase every element of a collection efficiently?

后端 未结 11 581
走了就别回头了
走了就别回头了 2020-12-02 16:53

What\'s the most efficient way to lower case every element of a List or Set?

My idea for a List:

final List strings = new ArrayList<         


        
11条回答
  •  温柔的废话
    2020-12-02 17:33

    I don't believe it is possible to do the manipulation in place (without creating another Collection) if you change strings to be a Set. This is because you can only iterate over the Set using an iterator or a for each loop, and cannot insert new objects whilst doing so (it throws an exception)

提交回复
热议问题