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 9213043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:39:33+00:00 2026-06-18T01:39:33+00:00

Possible Duplicate: Java Hashmap: How to get key from value? Bi-directional Map in Java?

  • 0

Possible Duplicate:
Java Hashmap: How to get key from value?
Bi-directional Map in Java?

I want a key value data structure to use for Android App. I can use Map<K,V>, but in Map I can’t get key for particular Value.

Is there any good Java data structure using which I can retrieve key by value and vice-versa.

  • 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-06-18T01:39:34+00:00Added an answer on June 18, 2026 at 1:39 am

    You can use Map with entrySet and Map.Entry class to iterate and get both keys and values even if you don’t know any of the keys in the Map.

    Map <Integer,String> myMap = new HashMap<Integer,String>();
    
    Iterator<Entry<Integer, String>> iterator = myMap.entrySet().iterator();
    while (iterator.hasNext()) {
        Map.Entry<Integer,String> pairs = (Map.Entry<Integer,String>)iterator.next();
        String value =  pairs.getValue();
        Integer key = pairs.getKey();
        System.out.println(key +"--->"+value);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Java Hashmap: How to get key from value? I have a hashmap
Possible Duplicate: Java Hashmap: How to get key from value? I know that a
Possible Duplicate: Get generic type of java.util.List I have a Map and I want
Possible Duplicate: How to sort a Map<Key, Value> on the values in Java? Dear,
Possible Duplicate: How to sort a Map<Key, Value> on the values in Java? I
Possible Duplicate: Java.util.HashMap — why HashMap extends AbstractMap and implement Map? In java to
Possible Duplicate: Java: Get first item from a collection In Java, I often encounter
Possible Duplicate: Table like java data structure I am looking for a Table-like data
Possible Duplicate: Java Ordered Map I have list of product object in the HashMap<Integer,Product>
Possible Duplicate: Java - HashMap vs Map objects What's the difference between : Map

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.