how to loop through dictionary in java

https://w‮tual.ww‬turi.com
how to loop through dictionary in java
/**
 * @author lautturi.com 
 * Java example: traverse/iterate over/through  dictionary in java 
 */

import java.util.*;

public class Lautturi {
	public static void main(String[] args) {

		Dictionary<Integer, String> dict = new Hashtable<Integer, String>();

		dict.put(1, "Java");
		dict.put(2, "Python");
		dict.put(3, "C++");
		dict.put(4, "l autturi.com");
		dict.put(5, "JavaScript");

		Enumeration<Integer> e = dict.keys();
		while (e.hasMoreElements()) {
			Integer key = e.nextElement();
			String value = dict.get(key);
			System.out.print("key:" + key);
			System.out.println(" value:" + value);
		}

	}
}

output:

key:5 value:JavaScript
key:4 value:l autturi.com
key:3 value:C++
key:2 value:Python
key:1 value:Java
Created Time:2017-10-03 23:10:49  Author:lautturi