I have a method where I build a LinkedHashMap
so I can preserve order. Here is my method:
public class MyClass {
public Map<String,MyObj> buildMap() {
Map<String,MyObj> myMap = new LinkedHashMap<>();
//perform logic and add objects to myMap
...
return myMap;
}
}
When I'm calling my buildMap()
function from another class, would I get a map that is in order still? Like:
MyClass myClass = new MyClass();
Map<String, MyObj> returnedMap = myClass.buildMap();
would my returnedMap
still be a LinkedHashMap
?
Or would I have to change my buildMap
function to always return a LinkedHashMap
?