Count number of values of a list having same hash value in java?

Don’t know if I understand exactly what u want but if u want to find in that map how many records have a value u should use it like this :

public static void main(String[] args) {
    Map<String, List<String>> invertedindex = new HashMap<String, List<String>>();
    List<String> myList = new ArrayList<>();
    invertedindex.put("book", myList);
    invertedindex.put("book2", myList);
    int count_ = Collections.frequency(invertedindex.values(), myList);

This will print 2.

Browse More Popular Posts

Leave a Comment