How about:
Map map1 = ...;
Map map2 = ...;
Map result = new ...(map1);
result.keySet().retainAll(map2.keySet());
or:
Map map1 = ...;
Map map2 = ...;
Set result = new ...(map1.keySet());
result.retainAll(map2.keySet());
More Related Contents:
- How do I efficiently iterate over each entry in a Java Map?
- How can I initialise a static Map?
- How to directly initialize a HashMap (in a literal way)?
- Sort a Map by values
- How do I convert a Map to List in Java?
- Java – How to create new Entry (key, value)
- How to Maintain order of insertion [duplicate]
- Count number of values of a list having same hash value in java?
- What is the difference between "collection" ,"Collection" and "Collections"? [duplicate]
- Difference between
- Properly removing an Integer from a List
- Java Class that implements Map and keeps insertion order?
- Randomly select an item from a list
- Define a fixed-size list in Java
- Maximum size of HashSet, Vector, LinkedList
- How to shuffle an ArrayList [duplicate]
- How can I generate a list or array of sequential integers in Java?
- what’s a good persistent collections framework for use in java?
- Is there a way to get the value of a HashMap randomly in Java?
- Difference between a deprecated and a legacy API?
- Any implementation of Ordered Set in Java?
- JDK9 randomization on immutable sets and maps
- In what situations is the CopyOnWriteArrayList suitable? [duplicate]
- What Java 8 Stream.collect equivalents are available in the standard Kotlin library?
- Create a List of primitive int?
- How do you create a dictionary in Java? [closed]
- Partial search in HashMap
- Java collections covariance problem
- How to do map inversion with Guava with non-unique values?
- Consumer mapped Class in HashMap