• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to Iterate HashMap of type HashMap<String, ArrayList<String>>  RSS feed

 
Anu satya
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
I am trying to iterate the hash Map. But, I am getting error at "for loop" please help.
I want the each value in the arraylist and do some string manipulation.



Please help
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all, declare your map like this (line 14):

Then you can get rid of the casts in lines 18 and 22.

I tried your code and it worked without errors!

You most likely have a class that you wrote yourself that is called Map, and Java is getting confused, it takes your own class Map instead of the Map from java.util. Rename or delete your own class Map.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!