import collection.JavaConversions._ val h = getJavaHashMapFromSomeWhere() for (e <- asScalaSet(h.entrySet())) { System.out.println(e.getKey() + " = " + e.getValue()) }
Programming Tips - Scala: How to iterate through all keys/values of a HashMap
Date: 2013may27
Update: 2025oct23
Language: Scala
Keywords: enumerate
Q. Scala: How to iterate through all keys/values of a HashMap
A. Use asScalaSet() like this: