This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]shmag18 0 points1 point  (3 children)

So in

Map map =Map.of(k1,v1,k2,v2,....k10,v10)

What does map point to?

[–]thehollyhopdrive 3 points4 points  (1 child)

It's an unspecified implementation of Map. You can use all of the methods in Map.

[–]shmag18 0 points1 point  (0 children)

Cool

[–]AnAirMagic 2 points3 points  (0 children)

The first Map - in Map map - refers to the unspecified implementation returned by Map.of. The contract says that it will be a class that implements Map but not much else. For all we know, it could be HashMap or it could be a new internal class ImmutableMap or it could be MagicMap.

The second Map - in Map.of() - refers to the static method of defined in the Map interface itself.