package com.codegym.task.task08.task0804;
import java.util.HashMap;
import java.util.Map;
/*
Display a list of keys
*/
public class Solution {
private static String pair;
public static void main(String[] args) throws Exception {
HashMap<String, String> map = new HashMap<String, String>();
map.put("Sim", "Sim");
map.put("Tom", "Tom");
map.put("Arbus", "Arbus");
map.put("Baby", "Baby");
map.put("Cat", "Cat");
map.put("Dog", "Dog");
map.put("Eat", "Eat");
map.put("Food", "Food");
map.put("Gevey", "Gevey");
map.put("Hugs", "Hugs");
printKeys(map);
}
public static void printKeys(Map<String, String> map) {
//write your code here
HashMap<String, String> m = new HashMap<>();
for(HashMap.Entry<String,String> pair : map.entrySet());
System.out.println(pair);
}
}
why it prints null?
Resolved
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
Guadalupe Gagnon
27 December 2018, 21:30solution
Please attach your code like this next time:
your problem is that you have a ';' at the end of your for loop:
also, you are suppose to only print the keys in this lesson. Change the code here to print the key only:

+7
Raisa Toscano
27 December 2018, 21:38
thanks you're right!!
0