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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:30:05+00:00 2026-06-06T00:30:05+00:00

Map<Integer, Map<String, String>> movie = new HashMap<Integer,Map<String, String>>(); Map<String,String> sub = new HashMap<String,String>(); I’m

  • 0
Map<Integer, Map<String, String>> movie = new HashMap<Integer,Map<String, String>>();
Map<String,String> sub = new HashMap<String,String>();

I’m doing this to populate and trying to iterate it:

Iterator<Element> releases = doc.select(
                    "div.pmovie > div.releases > div.release").iterator();
        Iterator<Element> subt = doc.select(
                "div.release-info > div.section > div.links > div > a")
                .iterator();
        int movindex = 1;
        while (subt.hasNext()) {
            Element rel = releases.next();
            Element subti = subt.next();
            release = rel.text();
            Log.v("RELEASES", release);
            subtitulo = subti.attr("href");
            Log.v("SUBTITULO", subtitulo);
            sub.put(release,subtitulo);
            movie.put(movindex, sub);
            movindex++;

        }

for (Entry<Integer, Map<String,String>>  entry : movie.entrySet()) {    
             key = entry.getKey();
             sub = entry.getValue();
                    for (Entry<String,String> entrada : sub.entrySet()) {

                        subtitle = entrada.getKey();
                        ruta = entrada.getValue();
               Log.v("SUB ITERATOR", key+" "+subtitle);


            }

The problem I’m reaching is with the inner “for”. It is getting all the “sub” Map values when I’m only need the pair (K,V) referenced by the outer Map key values.
What is the correct way to iterate this Map inside a Map? How can I a reach an specific (K,V) from the inner Map using the key of the outer Map?

Thanks!

  • 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-06T00:30:07+00:00Added an answer on June 6, 2026 at 12:30 am

    What you are trying to achieve is not very clear. But the problem probably is in the way you populate the map. You use the same sub for all the keys hence they all point to that same map which contains all the records. You should probably assign a new HashMap<String, String>() to sub every time you increment movieIndex.

    But if you do that, based on your code sample, each key (movieindex) will point to a map that contains only one entry.

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

Sidebar

Related Questions

I have for instance this Map: Map<String, Integer> map = new HashMap<String,Integer>(); than I
Hi I am having an error running this code Map<String, Integer> map = new
Code: public class MyClass { private Map<Integer,String> myMap; ........................... void methodFillMap(){ myMap=new HashMap<Integer, String>();
Code: public class MyClass { private Map<Integer,String> myMap=new HashMap<Integer, String>(); ........................... void methodFillMap(){ myMap.put(.....);
Given a map such as: Map<String, Integer> = new Hashmap<String, Integer>; How can I
I have a nested map: Map<Integer, Map<Integer, Double>> areaPrices = new HashMap<Integer, Map<Integer, Double>>();
is final Map<Integer,Map<String,Integer>> status = new ConcurrentHashMap<Integer, Map<String,Integer>>(); Map<Integer,Map<String,Integer>> statusInner = new ConcurrentHashMap<Integer, Map<String,Integer>>();
If I have following map: NavigableMap<Integer,String> nmap = new TreeMap<Integer,String>(); nmap.put(3, Three); nmap.put(1, One);
I have one Map that contains some names and numbers Map<String,Integer> abc = new
I need a Map<Integer,String> with a major need to do fast retrievals of values

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.