I have two maps and I need to check if both has the same keys and same number of keys or not and return a boolean. I would like to use streams for this and I have got is by creating another list
mapA
.entrySet()
.stream()
.filter(entry -> mapB.containsKey(entry.getKey()))
.collect(
Collectors.toMap(Entry::getKey, Entry::getValue));
But my question is that can I do it in a single line that would not create another list but return a boolean whether if they are same or not.