Search:

Type: Posts; User: copeg

Search: Search took 0.16 seconds.

  1. Thread: Student TreeMap

    by copeg
    Replies
    6
    Views
    4,168

    Re: Student TreeMap

    Did you also override hashCode()?



    @Override public int hashCode(){
    return studentId;
    }
  2. Thread: Student TreeMap

    by copeg
    Replies
    6
    Views
    4,168

    Re: Student TreeMap

    Because you are adding the Student object to your TreeMap, you should over-ride them in that class (similar to the equals you posted). It might be a bit trickier to override them though if you wish...
  3. Thread: Student TreeMap

    by copeg
    Replies
    6
    Views
    4,168

    Re: Student TreeMap

    When placing classes you wrote into classes which implement Map and Set interfaces, you need to make sure that the equals() and hashCode() methods are overridden. Because of the hash based retrieval...
Results 1 to 3 of 3