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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:16:20+00:00 2026-06-03T23:16:20+00:00

Hi, I wanted to store key and value of a nested Map that looks

  • 0

Hi, I wanted to store key and value of a nested Map that looks like this:

Map<ArrayList <String>, Map<String, Integer>> NestedMap = new HashMap<ArrayList<String>, Map<String, Integer>();

into another variable let say getKeyFromInsideMap and getValueFromInsideMap. So it would be the values of the inside Map String and Integer that am interested in accessing. How do I this in a code?

I tried several examples here in the forum but I don’t know how the syntax would look like. Could you please provide some code for this. Thank you!

  • 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-03T23:16:22+00:00Added an answer on June 3, 2026 at 11:16 pm

    You get the values from the nested by Map the same way as you get them from an unnested Map, you just have to apply the same process twice:

    //Java7 Diamond Notation
    Map<ArrayList, Map<String, Integer>> nestedMap = new HashMap<>();
    
    //get nested map 
    Map<String, Integer> innerMap = nestedMap.get(some_key_value_string);
    
    //now get the Integer value from the innerMap
    Integer innerMapValue = innerMap.get(some_key_value_string);
    

    Also if you are looking for a specific key, you can iterate over the map like so:

    Iterator it = map.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry pairs = (Map.Entry)it.next();
        System.out.println("Key: " + pairs.getKey() + " Val: " + pairs.getValue()));
        it.remove(); // avoids a ConcurrentModificationException
    }
    

    this will iterate over all of the keys and value of a single map.

    Hope this helps.

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

Sidebar

Related Questions

I needed to store various strings in a map but I wanted to keep
We are storing our data in an internal key-value store in few different data
I'm trying to decide which datastructure to use to store key-value pairs when only
I have a dictionary like class that I use to store some values as
I wanted to store 10 in 4th position of array of 5 positions. How
i have several classes with members called 'Id'. Originally i wanted to store these
i wanted to know where we should store the db in our project and
We have a multi-store set up and I wanted to change the template slightly
I had not run into this before but I wanted to know if it's
I'm new to database design and I considering implementing something that will be time

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.