import java.util.Collections;
import java.util.HashMap;
import java.util.stream.Collectors;
public class MapDuplicateDisplay {
public static void main(String[] args) {
HashMap hm=new HashMap<>();
hm.put(12, "twelve");
hm.put(3,"three");
hm.put(1, "four");
hm.put(1,"one");
hm.put(6,"three");
hm.entrySet().stream().filter(duplicates -> Collections.frequency(hm.values(), duplicates.getValue()) >1).collect(Collectors.toList()).forEach(System.out::println);
}}
Comments
Post a Comment