Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

How to iterate hashmap entries in java

// Creating a HashMap
Map<String, String> langTable = new HashMap<String, String>();
 
// Inserting elements to HashMap
langTable.put("A", "Angular");
langTable.put("J", "Java");
langTable.put("P", "Python");
langTable.put("H", "Hibernate");
 
// Iterating HashMap using foreach
for (Map.Entry<String, String> set : langTable.entrySet()) {
	// Printing all elements of a Map
	System.out.println(set.getKey() + " = " + set.getValue());
}
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #How #iterate #hashmap #entries #java
ADD COMMENT
Topic
Name
2+9 =