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

  • Home
  • SEARCH
  • 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 4612880
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:27:57+00:00 2026-05-22T01:27:57+00:00

I have Map <A, List<A>> map = new HashMap<A, List<A>>(); Say I want to

  • 0

I have Map <A, List<A>> map = new HashMap<A, List<A>>();

Say I want to print out each element in List<A> via an enhanced for loop

doing map.get(KeyOftypeA) does not return an iterable list…seems it returns a generic Object what do I do to get back the nice list i input and make it iterable?…

EDIT: Here’s the full listing of the code I am trying to run

import java.util.*;



public class StuffTag {

    public static void main (String[]args){
        String stuff;
        List<String> tags = new ArrayList();
        Map<String,List<String>> stuff_tags = new HashMap<String,List<String>>();
        List<Map> list_stuff_tags = new ArrayList();

        stuff="David and Goliath";
        tags.add("fire");
        tags.add("water");
        tags.add("smoke");
        tags.add("paper");

        stuff_tags.put(stuff, tags);
        list_stuff_tags.add(stuff_tags);
        Map el =list_stuff_tags.get(0);
         for(String x:el.get("David and Goliath"))
             System.out.println(x);

    }

}
  • 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-22T01:27:58+00:00Added an answer on May 22, 2026 at 1:27 am

    You need to define type of Map el e.g, Map<String,List<String>> el =list_stuff_tags.get(0);
    this will work for you.

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

Sidebar

Related Questions

let say I have this code Map<String, String> list = new HashMap<String, String>(); list.put(number1,
I have the following code private Map<KEY, Object> values = new HashMap<KEY, Object>(); public
Possible Duplicate: Get generic type of java.util.List I have a Map and I want
If I have a Map like this: HashMap<Integer, ComparableObject> map; and I want to
I want to have a map that has a homogeneous key type but heterogeneous
I have a list of objects say, List. The Entity class has an equals
I have a Map of Lists with key = GROUP and value = List
I have found this example on StackOverflow: var people = new List<Person> { new
I have declared the following method: private void mockInvokeDBHandler(Map<String, Object>... rows) { List<Map<String, Object>>
I have String arrays of arrays. List<String[]> mainList = new ArrayList<String[]>(); String[] row1 =

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.