Collection of bad coding practices

Posts Tagged ‘iterator

Accessing the Map values using keySet iterator

with 13 comments

A common mistake is to retrieve values from a Map while iterating over the Map keys with keySet(). Calling Map.get(key) for each entry is expensive and should be avoided for better performance.

Use entrySet() iterator to avoid the Map.get(key) lookup.

Read the rest of this entry »


Written by Alex

November 22, 2007 at 12:02 pm

Posted in Collections

Tagged with , , ,