Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7016909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:50:47+00:00 2026-05-27T22:50:47+00:00

I implemented two Hashtable as shown below. HashMap<Integer,String> streetno=new HashMap<Integer,String>(); streetno.put(1, Sachin Tendulkar); streetno.put(2,

  • 0

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??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:50:48+00:00Added an answer on May 27, 2026 at 10:50 pm

    You can read the input as mentioned in other answers. I just tried the main logic in this way. If combining two maps can be done, you can try this way.

                String input = "Laxman";            
                HashMap<String, String> street = new HashMap<String, String>();
                street.put("1", "Sachin Tendulkar");
                street.put("2", "Dravid");
                street.put("3", "Sehwag");
                street.put("4", "Laxman");         
    
                for (Map.Entry<String, String> entry : street.entrySet()) { 
                    System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
                    if (input.equals(entry.getKey())) {
                        System.out.println(entry.getValue());   
                        break;
                    } else if (input.equals(entry.getValue())) {
                        System.out.println(entry.getKey());   
                        break;
                    }               
                }                
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have implemented the two classes shown at http://tomcat.apache.org/tomcat-6.0-doc/aio.html which gives a messenger application
I have two SharePoint features, each implemented identically (see below), that add controls to
Which of the following has the best performance? I have seen method two implemented
I have implemented inheritance for two parent classes called Table and Field . Each
Two function should be implemented, and I am wondering what type of validation I
I implemented a small OOP library in Lua, and two things are not quite
How can the XOR operation (on two 32 bit ints) be implemented using only
I'm currently using two libraries (prototype and jQuery), thus I've implemented the jQuery noConflict
I implemented two actions : The first action it renders Address view with consumer
I've implemented two REST services: Twitter and Netflix. Both times, I struggled to find

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.