I have the following hash map
Map<String,Double> map_1 = new LinkedHashMap<>();
with some keys: e.g. ["hello_1", "hello_2", "hello_3"].
Then, I iterate through these keys using stream API and saving new results in map2:
Map<String,Double> map_2 = new LinkedHashMap<>();
map_2 = map_1.keySet()
.stream()
.collect(
Collectors.toMap(entry -> entry,
entry -> {
Double value = map_1.get(entry);
return (value + 5);
}));
but the new hash map has keys in another order, despite it is defined as LinkedHashMap. I think the problem is during stream + collect steps.
Anyone could suggest me a solution? Thanks