import com.google.common.collect.Maps; import java.util.HashMap; import java.util.Map; import java.util.function.Predicate; public class Example { public static void main(String[] args) { MapIn this example, we use filterValues to create a new map called filteredMap containing only the entries whose values are even. We define the predicate inline as a lambda function that returns true if the value is even. The resulting filteredMap only contains the entries for "banana" and "durian", whose values are 2 and 4 respectively. com.google.common.collect is the package for the Google Guava library.originalMap = new HashMap<>(); originalMap.put("apple", 1); originalMap.put("banana", 2); originalMap.put("cherry", 3); originalMap.put("durian", 4); Map filteredMap = Maps.filterValues(originalMap, new Predicate () { public boolean test(Integer value) { return value % 2 == 0; } }); System.out.println(filteredMap); // prints "{banana=2, durian=4}" } }