FindBugs warning: Inefficient use of keySet iterator instead of entrySet iterator

前端 未结 5 1557
别跟我提以往
别跟我提以往 2021-02-06 23:20

Please refer to the following method :

public Set getCellsInColumn(String columnIndex){
    Map cellsMap = getCell         


        
5条回答
  •  终归单人心
    2021-02-06 23:54

    In keyset, you need to get all the keys and then you search for every key in the collection.

    Moreover, loop over the entrySet is faster, because you don't query the map twice for each key.

    If you need only keys or only values of your Map, then use rather keySet() or values().

提交回复
热议问题