- Insert values into HashMap
- Retrieve values from HashMap
import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; /** * * @author JSupport * http://javasrilankansupport.blogspot.com * */ public class InsertRetrieveDataFromMap { // get values from HashMap public static void getHashMapData(Map order_details){ Set key_set; // gat all key to Set key_set = order_details.keySet(); for (Iterator it = key_set.iterator(); it.hasNext();) { String key = (String) it.next(); String value = (String) order_details.get(key); System.out.println("Map key : "+key +"\tKey Value : "+key); } } public static void main(String[] args) { HashMap order_details = new HashMap(); // add key value pairs to HashMap order_details.put("kitchName", "Chinese Kitchen"); order_details.put("waiterName", "Silva"); order_details.put("tableName", "20"); getHashMapData(order_details); } }
This program dose answer to following....
- How to Insert values into HashMap in Java
- How to Insert values into HashMap in Java
- How to Retrieve values from HashMap in Java
- How to Retrieve values from Map in Java
0 comments:
Post a Comment