Let’s say I have 2 Map’s in Java. I want to compare map1’s keys to map2’s keys to see if there are any similar keys in the 2 maps.
How can i do that?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you don’t want to modify the maps:
Finding the common keys:
If your keys are dates, they should probably be something
Comparable, in which case you might want a TreeSet instead of a HashSet, because it will keep them in order.