Create Map in Java

Kevin Meredith picture Kevin Meredith · Feb 7, 2013 · Viewed 282k times · Source

I'd like to create a map that contains entries consisting of (int, Point2D)

How can I do this in Java?

I tried the following unsuccessfully.

HashMap hm = new HashMap();

hm.put(1, new Point2D.Double(50, 50));

Answer

hd1 picture hd1 · Feb 7, 2013
Map <Integer, Point2D.Double> hm = new HashMap<Integer, Point2D>();
hm.put(1, new Point2D.Double(50, 50));