Now I come to my first impasse. I can't return a LinkedHashMap
Here's the misunderstanding: you can return a LinkedHashMap
, because a LinkedHashMap
is a Map
, a particular sort of Map
, but a Map
anyway.
Can someone explain what is happening to map when it gets passed?
When it's passed, it is seen as any Map
, like incognito, but it remains the same.
Is it still a LinkedHashMap?
Yes.
Is the data changed at all?
No.
What would happen to the order of the Map if, after calling getData(), I put something in the Map?
This is another topic.
Why wouldn't/shouldn't I just define the Map as in the second code snippet?
You needn't do that, since a LinkedHashMap
is a Map
(on the other hand, a Map
is not necessarily a LinkedHashMap
).
Is my method of getting the map done in ignorance? Should I just make map public?
No.