Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: what is wrong with my code? please help

  1. #1
    Junior Member
    Join Date
    Dec 2012
    My Mood
    Thanked 0 Times in 0 Posts

    Smile 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)
    // addAnimalEntry();
    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);

    return ret;


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Eastern Florida
    Thanked 2,475 Times in 2,426 Posts

    Default Re: what is wrong with my code? please help

    Did you have a question?

    Please edit your post and wrap your code with
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Not sure what is wrong with this code?? Please help
    By sim18 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: October 21st, 2012, 08:22 AM
  2. What's Wrong With My Code?
    By Nuggets in forum What's Wrong With My Code?
    Replies: 11
    Last Post: January 31st, 2012, 10:11 PM
  3. What's wrong with my code?
    By mjballa in forum What's Wrong With My Code?
    Replies: 8
    Last Post: November 19th, 2011, 03:57 PM
  4. need help .. what is wrong with my code.
    By baig-sh in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 10th, 2011, 07:28 PM
  5. what's wrong with this code
    By gcsekhar in forum Java Networking
    Replies: 5
    Last Post: July 21st, 2011, 06:01 AM

Tags for this Thread