Skip to content

Instantly share code, notes, and snippets.

@baladkb
Created January 7, 2017 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baladkb/26380ca7b0cbd56a02d4c19ebb13d3a1 to your computer and use it in GitHub Desktop.
Save baladkb/26380ca7b0cbd56a02d4c19ebb13d3a1 to your computer and use it in GitHub Desktop.
import java.util.HashMap;
import java.util.Map;
public class HASMAPCompare {
public static void main(String[] args) {
final Map<String, String> hm1 = new HashMap<String, String>();
hm1.put("01", "Bala");
hm1.put("02", "Sha");
hm1.put("03", "Sha");
final Map<String, String> hm2 = new HashMap<String, String>();
hm2.put("01", "Bala");
hm2.put("02", "Sha0");
final Map<String, String> hm3 = new HashMap<String, String>();
for (final String key : hm1.keySet()) {
if (hm2.containsValue(hm1.get(key))) {
hm3.put(hm1.get(key), hm2.get(key));
}
}
System.out.println(hm3.size());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment