Q:

How do i find a value stored in a linked list than in turn is stored in a hashmap

I have the following hashmap, that stores string keys and linked list values
public HashMap<String, LinkedList<String>> wordIndex = new HashMap<>();

My wordIndex contains multiple linked lists that contains the word "algorithms", so I wrote the following code to see if my hashmap is able to find the word "algorithms"
String getWord(String query) { //query=user input in this case algorithms

    if(wordIndex.containsValue(query.toLowerCase()))
    {
        return "hello";          //should return hello if word is found
    }
    else
    {
        return "none";
    }       
}

However it is always returning none, which means it can find the word in the linked list. 
So what is the correct procedure to traverse through linked Lists inside Hashmaps.  I searched but couldn't find any answer. 
Also I need to return all the KEYS, containing the query word (in this case "algorithm").  I cant seem to find a function in the hashmap class that can do that(or maybe I saw it but didn't understand it).  I am new to hashmaps could you guys please help me out and point me in the right direction. 

A:

You can't do that.  If you want to check if there is the word in any LinkedList in the HashMap, you should do something like :
String getWord(String query) { //query=user input in this case algorithms
    for(LinkedList<String> l : wordIndex.values()) {
        if(l.contains(query.toLowerCase())) {
            return "hello";          //should return hello if word is found
        }
    }
    return "none";   
}

