2 Replies Latest reply: Mar 18, 2014 8:23 AM by jwenting RSS

    How hashset works in java


      In one of my java interview , i faced this question ,and i want to know the exact reason . I have found this blog http://javahungry.blogspot.com/  with this url Internal implementation of Set/HashSet (How Set Ensures Uniqueness) : Core Java Collection Interview Question , can anyone explain me in detail , means how hashset do rehashing and how it uses memory to store hashset object

        • 1. Re: How hashset works in java

          None of what you're asking about is relevant. The only material fact is that Set uses the equals() method to determine object equality, and that's in the Javadoc. HashSet and rehashing and 'how it uses memory to store HashSet object' have exactly nothing to do with it.

          • 2. Re: How hashset works in java

            and would be implementation dependent per JVM. I seriously doubt any competent interviewer would ask that as a question, far more likely OP misunderstood what he was being asked.