I tried to use for each loop to iterate through HashMap keys but it doesn't compile.
Here is my code:
import java.util.Map;
import java.util.HashMap;
public class theseeker{
public static void main(String[] args){
Map blue = new HashMap<Character,Integer>();
for(char c = 'a';c <= 'z';c++)
blue.put(new Character(c),new Integer((int)c));
for(Character c : blue.keySet())
System.out.println(c);
}
}
I get this error:
Object cannot be converted to Character
for(Character c : blue.keySet())
^
Does it happen beacuse of using interface?