So I have 2 questions about HashMaps in Java:
(1) What is the correct way to initialize a HashMap? I think it might be best in my situation to use:
HashMap x = new HashMap();
But Eclipse keeps suggesting that I use:
HashMap<something, something> map = new HashMap();
which is better?
(2) Can a HashMap hold different types of objects/data types as values? For example, would this work and be ok:
map.put("one", 1);
map.put("two", {1, 2});
map.put("three", "hello");
In the first put(), i want an int as a value, in the second an int[], and third a string. Is this okay to do in Java with HashMaps? Also, is it okay to store a HashMap as a value within a HashMap?