I implemented two Hashtable as shown below.
HashMap<Integer,String> streetno=new HashMap<Integer,String>();
streetno.put(1, "Sachin Tendulkar");
streetno.put(2, "Dravid");
streetno.put(3,"Sehwag");
streetno.put(4,"Laxman");
streetno.put(5,"Kohli");
HashMap<String,Integer> streetname=new HashMap<String,Integer>();
streetname.put("Sachin Tendulkar",1);
streetname.put("Dravid",2);
streetname.put("Sehwag",3);
streetname.put("Laxman",4);
streetname.put("Kohli",5);
Iterator itr=streetno.keySet().iterator();
Now I'm asking user for input. If he enters the integer I want to retrieve particular value from the 1st hash table and if user enter the string I want to read the particular integer from 2nd hashtable.
My question is "How can I read the input from the user??" Because I don't know whether user enters the integer or string?? And I also wanted to know Can I retrieve particular value using Iterator depending on the key??