12/13 Iterating over a HashMap: clarification


In both the example and the code provided, there are undeclared variables that I don't understand how HashMap knows what to do with them. Specifically I'm referring to name in the example and item in the code. HashMap seems to know to declare these variables as the type string without any written declaration. What if I wanted to do this to an integer or double type variable? Is it assigned automatically to the first variable type in the HashMap?


Just figured it out, totally spaced that this was within the parameter of a for each loop that declares name as a string. I'll leave this up in case it helps anyone else.


The variable item will be declared in the parenthesis after the "for" keyword. In the example you can see
for (String name: ...)
That's where the variable name is declared.