what is wrong with my code? please help
The GameKeeper class needs a second instance method called findEcoDiversity(int y) which takes an integer argument and returns a set of strings.
The method should iterate over each of the keys in animalMap. In each case where the number of strings in the corresponding value is greater than the threshold value indicated by the integer argument to the method, a message should be printed to the standard output as follows:
Area code X has more than Y kinds of animals
(where X and Y are filled in appropriately)
Finally, the method should return as message reply the last set of strings found (where the number of strings is greater than the threshold) or an empty list, if none were found.
public HashSet <String> findEcoDiversity(int y)
HashSet<String> ret = new HashSet<String>();
for(Character Key: animalMap.keySet())
if(animalMap.get(Key).size() > y)
System.out.println(" Area code " + Key + " has more than " + y + " animals ");
ret = animalMap.get(Key);
Re: what is wrong with my code? please help
Did you have a question?
Please edit your post and wrap your code with
<YOUR CODE HERE>
to get highlighting and preserve formatting.