retrieve kv pairs using hashmap

retrieve kv pairs using hashmap

i want to retrieve k,v-pairs from a hashmap. the entrys are like this:

a = 3,4 b = 5,6

and so on. i need combinations of these values.

a=3, b=5. a=3, b=6. a=4, b=5. a=4, b=6.

I don't know how many keys and how many entrys the values have. with entryset i can get the values but not combinations. it looks like recursion but how?

View Answers

January 26, 2012 at 5:58 PM

import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;


public class R2T2Generator {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub

        R2T2Generator r2t2generator=new R2T2Generator();
        Map<String,String[]>map=new TreeMap<String,String[]>();
        map.put("ProductSet",new String[]{"IA","EA"});
        map.put("role",new String[]{"Internal","External"});
        map.put("mode",new String[]{"D"});
        r2t2generator.mapPermute(map, "");
    }
    public void mapPermute(Map<String, String[]> map, String currentPermutation) {
        String key = map.keySet().iterator().next(); // get the topmost key

        // base case
        if (map.size() == 1) {          
            for (String value : map.get(key)) {
                System.out.println(currentPermutation + key + "=" + value);
            }
        } else {
            // recursive case
            Map<String, String[]> subMap = new TreeMap<String, String[]>(map);

            for (String value : subMap.remove(key)) {
                mapPermute(subMap, currentPermutation + key + "=" + value + ", ");
            }
        }
    }

}









Related Tutorials/Questions & Answers:
retrieve kv pairs using hashmap
retrieve kv pairs using hashmap  i want to retrieve k,v-pairs from a hashmap. the entrys are like this: a = 3,4 b = 5,6 and so on. i need combinations of these values. a=3, b=5. a=3, b=6. a=4, b=5. a=4, b=6. I don't know
how to load a table of data from oracle, to a jsp page using hashmap.
how to load a table of data from oracle, to a jsp page using hashmap. ... to this data i have to retrieve their details from the database(oracle). I have to use the hashmap.How can i convert a result set object to hashmap object
Advertisements
HashMap
HashMap  How to work hashmap and hashset internally
hashmap
hashmap  write a program that shows the use of Hashmap class
tO FIND UNIQUE WORDS IN A FILE USING HASHMAP
tO FIND UNIQUE WORDS IN A FILE USING HASHMAP  import java.util....() { // create a HashMap to store unique combination of words... HashMap map = new HashMap(); int cc=0; // populate the map
HASHMAP
HASHMAP  HI CAN WE ADD PRIMITIVE DATA TYPE IN HASHMAP IN JAVA 1.5 VERSION . THANKS KALINS NAIK   Java HashMap Example
Hashmap
Hashmap  Hi i want to date and day in hashmap , 1 want to display according to day with date, how to write aprograme
Hashmap
args[]){ HashMap hm=new HashMap(); hm.put(new Integer(2), "Two"); hm.put...*; public class HashTable { public static void main(String args[]){ HashMap hm=new HashMap(); hm.put(new Integer(2), "Two"); hm.put(new Integer(1
HashMap
HashMap  How can you get a HashMap to Display Text onto a Text Field that is defined and Set up to JPanel on a different Class static class public static Map <String, ActionListener> listener = new HashMap <String
Retrieve data using Criteria api
Retrieve data using Criteria api  import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Query; import org.hibernate.Criteria; import org.hibernate.criterion.Restrictions; import
HashMap in Java
HashMap class is used to implement Map interface. The value of HashMap is stored using get() and put(). HashMap provides key-value access to data. HashMap is almost equal to HashTable, the only difference is that HashMap allows null
Insert or retrieve image into oracle 10g by using java
Insert or retrieve image into oracle 10g by using java   How can i insert or retrieve image into oracle10g using java plz i need it urgently,need guidance to do this plz
How to Retrieve Data from Facebook Using PHP
How to Retrieve Data from Facebook Using PHP  is this link has right content regards that?? http://techpdf.co.cc/blog/how-to-retrieve-data-from-facebook-using-php
How to Retrieve Data from Facebook Using PHP
How to Retrieve Data from Facebook Using PHP  is this link has right content regards that?? http://techpdf.co.cc/blog/how-to-retrieve-data-from-facebook-using-php
Unable to bind to a hashmap from jsp using spring tags - Spring
Unable to bind to a hashmap from jsp using spring tags  Hi, I am unable to bind a hashmap from my jsp page. Here is what i want to do: I have... to bind with the hashmap dynamically.) On submission of the form i need the label
retrieve data from database using jsf
retrieve data from database using jsf  Hello I want an example of source code to retrieve data from database i have a database (oracle) name as db1...),, name ,and city I want after enter value in textbox according idauthor i retrieve
<img src=""> using retrieve image from database using jsp
using retrieve image from database using jsp  how to <img src="" > tag using retrieve image from database and display in jsp
HOW TO SAVE XML INTO MYSQL AND RETRIEVE IT USING JAVA
HOW TO SAVE XML INTO MYSQL AND RETRIEVE IT USING JAVA  H ello, i have an xml code, i need to save it into mysql 5.5 server database using java. i also want to be able to retrieve it as well. please note that i want it saved
Retrieve values from database using views
Retrieve values from database using views  hi......... I have a huge... the columns which are required. As my front end is java swings i want to retrieve data... giving me error . So can u plz help??????? Can u tell me how to retrieve data
Problem while using a HashMap for writing text ina RTF file. - Framework
Problem while using a HashMap for writing text ina RTF file.  Hi, I am trying to generate a RTF file using iText.jar, wherein I am taking...() { objHashMap = new HashMap(); objHashMap.put("Key1","DBMCCSSSSSSSSSSSSSSSSSSSSSSSS
Retrieve data from xml using servlets
Retrieve data from xml using servlets  Hi plz send me the code for retrieving the data from xml File using Servlets.   Hi, Do you want... File using ServletADS_TO_REPLACE_2 Thanks   Hi, Learn Get Data From
Retrieve the String using expression
Retrieve the String using expression       This Example describes the way to retrieve the String using expression.For this we are going to make program named NotLookahead.java.
Retrieve data from databse using where in JSP
Retrieve data from databse using where in JSP  Hi, can somebody help me? I have a jsp page. in that i want to get data from the database where username is matched. i tried it. but can't get the output. here is the code. please
Program to count the number of unique words in a file using HashMap
Program to count the number of unique words in a file using HashMap  import java.io.File; import java.io.FileNotFoundException; import java.util.*; public class CountUniqueWords { public static void main(String args
Query regarding hashmap
Query regarding hashmap  I want to store some names and ids in hashmap in session, then retrieve it on next page and iterate through ids to run a query using ids one at a time
how to store and retrieve images int and from the database using php
how to store and retrieve images int and from the database using php  please anyone can help me in storing the images and retrieve it back from the Mysql database using php
how to store and retrieve image using struts2 and hibernate integration
how to store and retrieve image using struts2 and hibernate integration  how to store and retrieve image using struts2 and hibernate integration? plz help !! thanks in advance
Java hashmap, hashtable
Java hashmap, hashtable  When are you using hashmap and hashtable
Retrieve database from the table dynamically in jsp from oracle using servlet
Retrieve database from the table dynamically in jsp from oracle using servlet  Sir, I have created a table in oracle using eclipse, and added few columns dynamically. I want to retrieve the table with all columns dynamically
How to retrieve image from database using jsp and servlet?
How to retrieve image from database using jsp and servlet?  Hi, I am trying to find code for displaying the image from database in a JSP page. How to retrieve image from database using jsp and servlet
How to Retrieve Data from the database and write into excel file using Java
How to Retrieve Data from the database and write into excel file using Java  Hi, I am trying to develop an small application where i trying to retrieve Data from the database and store the details in excel file. Please can
Retrieve hardware info of a PC using servlet - JSP-Servlet
Retrieve hardware info of a PC using servlet  Hi,I hav a query related to java servlets.I wanted to know how to retrieve the hardware information using java servlets?I had gone through this link http://www.roseindia.net/software
HashMap - Struts
HashMap  Can you please get me an example code for using HashMap in Jsp and what for what purpose it is used
Collection : HashMap Example
Collection : HashMap Example This tutorial will help you in understanding of HashMap concept. HashMap : The java.util.HashMap class implements Map... values that is each value has unique key through which we can retrieve
how to retrieve image from mysql using java - Java Beginners
how to retrieve image from mysql using java  hi i am using jsf and java IDE netbean,database mysql.how to retrieve image from mysql database. please help me   Hi friend, I am sending you a link. I hope
Retrieve image from database using servlet and display in JSP
Retrieve image from database using servlet and display in JSP  Hi, I am total new to JSP although I am learning it for the last few days. Now I want to use MySQL Database from JSP page. How to retrieve image from database using
How to retrieve data by using combo box value in jsp? - JSP-Servlet
How to retrieve data by using combo box value in jsp?  For example, In Employee.jsp form, When i click employee id value in combo box ,the related employee name will be displayed in text field
retrieve related data from database using jsp and mysql
retrieve related data from database using jsp and mysql  Hi sir, please give some example of jsp code for retrieving mysql database values in multiple dropdown list. if we change a value in a dropdown its related value must
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?   first registration with email , username, password after >> <> without
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?   first registration with email , username, password after >> <> without
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?   first registration with email , username, password after >> <> without
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?   first registration with email , username, password after >> <> without
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?   first registration with email , username, password after >> <> without
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?   first registration with email , username, password after >> <> without
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?   first registration with email , username, password after >> <> without
how to retrieve data from database using combobox value without using request.getParameter in jsp - JSP-Servlet
how to retrieve data from database using combobox value without using request.getParameter in jsp  Answer pl
How to retrieve data by using combo box value in jsp? - JSP-Servlet
How to retrieve data by using combo box value in jsp?  I am using a single jsp form.. i did not get from another form.. i do not use 2 jsp form.. all.... Note: I am using only this jsp form.. i do not use
How to get Keys and Values from HashMap in Java?
How to get Keys and Values from HashMap in Java? Example program of iterating through HashMap In this tutorial I will explain you how you can iterate through HashMap using the entrySet() method of HashMap class. You will be able
How to retrieve data using combo box value in jsp? - JSP-Servlet
How to retrieve data using combo box value in jsp?  Hi freind, I already post this question. I need urgent help from u. pl response me.... All actions in the same page.......  Hi Friend, Please visit
using getText() to retrieve text from an array of text fields with loop.
using getText() to retrieve text from an array of text fields with loop.   hi, I have an array of about 50 textfields which show up when somebody presses button. Now I want to get the text from all the textfields using array

Ads