Check if the key value exists in hashmap : <p>I have HashMap where key is bird specie and value is number of perceptions. Here is my code:</p>

<pre><code>public class Program {

public static void main(String[] args) {

    HashMap&lt;String, Integer&gt; species = new HashMap&lt;&gt;();
    Scanner reader = new Scanner(System.in);

    species.put("hawk (buteo jamaicensis)", 2);
    species.put("eagle (aquila chrysaetos)", 4);
    species.put("sparrow (passeridae)", 5);

    System.out.println("What specie?"); //output "chicken"
    String specie = reader.nextLine();

    for (HashMap.Entry&lt;String, Integer&gt; entry: species.entrySet()) {
        if (entry.getKey().contains(specie)) {
            System.out.println(entry.getKey()+" : "+entry.getValue()+" perceptions");
        } else {
            System.out.println("Not in database!");
        }
    } 
}
</code></pre>

<p>}</p>

<p>How I can check if the specie exists in hashmap? For example if the specie output is "chicken" and it's not in database, then the program should print "Not in database!". Now the output is:</p>

<pre><code>Not in database!
Not in database!
Not in database!
</code></pre>

<p>And my goal output is:</p>

<pre><code>Not in database!
</code></pre>
