Results 1 to 6 of 6

Thread: Difference between hashset and hashmap in java

  1. #1
    Join Date
    Dec 2009
    Posts
    68

    Difference between hashset and hashmap in java

    Hello Guys,

    According to me the advanced java is quit tough than core java. I am getting too much troubles while understanding the hashset and hashmap. I want to know about the difference between the hashset and hashmap.I have read different java book, but nothing was useful. I wonder if you provide me some difference between hashset and hashmap with suitable example. I am waiting for your reply.

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Re: Difference between hashset and hashmap in java

    Hi,

    A HashSet is identical to HashTree in java except that it preserves the insertion order of elements in a doubly linked list. In HashSet the iteration order of the elements corresponds to the insertion order, the order remains unchanged if one adds an element already present.The operations add, remove, contains and size are executed in constant time (but greater than the time the HashSet as it must also manage the linked list).

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Difference between hashset and hashmap in java

    The java.util.HashSet integrates the "HashSet" . It is the most useful implementations. In "HashSet" the iteration order of the elements is random. But the operation like remove, add is quit complicate in "HashSet" as compare to "Hashmap". In "HashMap" these operation are executed in constant time. "Hashset " is the concrete implementations of the API. Class java.util.HashMap implementation is the most practical standard is suitable for most situations.

  4. #4
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Difference between hashset and hashmap in java

    Hi Friend,

    The various existing collections (HashSet, ArrayList, HashMap) are based on the equals and hashmap objects, it is strongly advised to override to use the methods provided by the API. A Hashmap used to create a set of key / value pairs (also known as associative arrays), the key to quickly find the value that has been associated. The keys are unique items that can be NULL; values can be multiple and null.

  5. #5
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Difference between hashset and hashmap in java

    The class java.util.LinkedHashMap remember the order of addition of keys.The class keeps java.util.WeakHashMap couples using weak references, so if the key is no longer referenced elsewhere in the program, the couple is automatically deleted from the collection. The HashMap enables very fast access to a mapping. For this it uses the unique key to a value. The value of the HashSet are always unordered.

  6. #6
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Difference between hashset and hashmap in java

    Hi,

    Following are some constructors of "HashMap":
    • HashMap(int Capacity)
    • HashMap(Map mp)
    • HashMap()
    • HashMap(int Capacity, float loadFactor)

Similar Threads

  1. Non-unique element in HashSet
    By New ID in forum Software Development
    Replies: 5
    Last Post: 20-02-2010, 12:57 AM
  2. Listener support for a HashSet
    By Remedy in forum Software Development
    Replies: 5
    Last Post: 10-02-2010, 04:10 AM
  3. what is the difference between c and java?
    By Linoo in forum Software Development
    Replies: 5
    Last Post: 28-11-2009, 05:11 PM
  4. Difference between Applet and Japplet in java
    By Jalabala in forum Software Development
    Replies: 3
    Last Post: 21-11-2009, 07:48 AM
  5. What is the difference between CORBA and Java RMI?
    By Triple-X in forum Software Development
    Replies: 3
    Last Post: 03-09-2009, 05:59 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,058,298.54191 seconds with 17 queries