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));
Add Items to make a Map To make a map, place 8 papers and 1 compass on Java Edition (PC/Mac), Xbox and PS in the 3x3 crafting grid. In PE and Windows 10, you need 9 papers to make a map.
Java HashMap is a class which is used to perform operations such as inserting, deleting and locating elements in a map. We create a map, where we pass two kinds of values which are 'key' and 'value'.
The HashMap class of the Java collections framework provides the functionality of the hash table data structure. It stores elements in key/value pairs. Here, keys are unique identifiers used to associate each value on a map. The HashMap class implements the Map interface.
Map <Integer, Point2D.Double> hm = new HashMap<Integer, Point2D>(); hm.put(1, new Point2D.Double(50, 50));
Java 9
public static void main(String[] args) { Map<Integer,String> map = Map.ofEntries(entry(1,"A"), entry(2,"B"), entry(3,"C")); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With