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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:42:07+00:00 2026-05-24T02:42:07+00:00

So essentially, I have two hashmaps, one containing the following values: rId33=image23 rId32=image22 rId37=image2

  • 0

So essentially, I have two hashmaps, one containing the following values:

rId33=image23
rId32=image22
rId37=image2

And the other containing this data:

{image2.jpeg=C:\Documents and Settings\image2.jpeg, image22.jpeg=C:\Documents and Settings\image22.jpeg, image23.jpeg=C:\Documents and Settings\image23.jpeg}

I basically want to be able to iterate through the first map, find a match of the key’s, if a match is found, get the associated value, then look in the second map, find a match in the keys, then pull out the associated value (meaning the file path).

I was thinking of doing something like this for example (the follow is simplified)…

String val2 = "rId33";

for (String rID: map.keySet())
{
     if (rID.contains(val2))
     {
         //enter code here
     }
}

I was looking at the methods available for something like .getValue or something, but I’m not entirely sure how to do that. Any help would be appreciated. Thanks in advance for any replies.

Edited Code with Help From Bozho

else if ("v:imagedata".equals(qName) && headingCount > 0)
{
    val2 = attributes.getValue("r:id");
    String rID = imageMap.get(val2);
    String path = imageLocation.get(rID + ".jpeg");

    for (String rels: imageMap.keySet())
    {
        if (rels.contains(val2))
        {
        inImage = true;
        image docImage = new image();

        imageCount++;

        docImage.setRelID(val2);
        docImage.setPath(path);
        addImage(docImage);
        }
    }
  • 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-24T02:42:08+00:00Added an answer on May 24, 2026 at 2:42 am

    From what I see you don’t need to iterate. Just:

    String value1 = map1.get(key1);
    if (value1 != null) {
        String path = map2.get(value1 + ".jpeg");
    }
    

    If you don’t always know whether it’s value1 + ".jpeg", but you just know that the key starts with the first value, then you can iterate the 2nd map with:

    for (Map.Entry<String, String> entry : map2.entrySet()) {
        String key2 = entry.getKey();
        String value2 = entry.getValue();
        if (key.startsWith(value1)) {
            return value2;
        }
    }
    

    But note that the first code snippet is O(1) (both operations take constant time), while the 2nd is O(n)


    And to answer the question as it is formulated in the title:

    Get the iterators of both maps, and use it1.next() and it2.next() within a while loop. If any of the maps doesn’t have more elements (it.hasNext()) – break.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables containing data that are essentially headline lists from different sources.
I have two images. One could be any size and aspect ratio. The other
So essentially I have two tables, containing URLS and TAGS, with a has-and-belongs-to-many relationship
I have two divs that are not nested, one below the other. They are
I have two essentially separate applications for configuring two pieces of hardware sold by
I have two variables. weekStartDate and startDate. they both hold essentially the same timestamp:
What I'm talking about here are nested classes. Essentially, I have two classes that
Essentially I have to use a poorly implemented web service maintained by other programmers.
So I have two nodes of elements that I'm essentially trying to join. I
Essentially I have two different flat files Credit & Account with different record structures.

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.