package com.codegym.task.task08.task0806;
import java.util.HashMap;
import java.util.Map;
/*
HashMap of Objects
*/
public class Solution {
public static void main(String[] args) throws Exception {
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("Sim", new Integer(5));
map.put("Tom", new Double(5.5));
map.put("Arbus", new Boolean(false));
map.put("Baby", new String("Zach"));
map.put("Cat", "Cat");
map.put("Eat", new Long(56));
map.put("Food", new Character('3'));
map.put("Gevey", new Character('6'));
map.put("Hugs", new String("111111111111L"));
map.put("Comp", new Double(123));
//write your code here
for (Map.Entry<String, Object> person : map.entrySet())
{
String key = person.getKey();
String value = person.getValue().toString();
System.out.println(key + " - " + value);
}
}
}
Don't see the problem but last task will not pass
Under discussion
Comments (3)
- Popular
- New
- Old
You must be signed in to leave a comment
Guadalupe Gagnon
25 February 2021, 22:41
It looks like you changed a bunch of the values between lines 14-23. I would recommend resetting the task and not doing that next attempt.
0
Gellert Varga
25 February 2021, 22:13
I think the getValue() method is able to do the job, so it is able to give to You the needed value, and you don't need use the toString() method.
0
Gellert Varga
25 February 2021, 22:18
Just insert the 'person.getValue()' inside the Sys.o.print() command.
0