I have two maps:
Map<String, Sample> newMap = convertJSONObjectToSampleMap(newMapStr);
Map<String, Sample> oldMap = convertJSONObjectToSampleMap(oldMapStr);
the Sample
is some custom class
The newMap
has keys: [1,2,3,4,5]
The oldMap
has keys: [2,3,4,5,8]
What is the best way to get difference between them, .e, get Sample
s with keys: 1
and 8
?
I thought to use Collections
and extract Set<>
:
Set<String> newSet = newMap.keySet();
Set<String> oldSet = oldMap.keySet();
Thank you,