Hi,
A HashSet is implemented with a backing HashMap structure. In other words, a HashSet uses a hash table as the underlying data structure to represent a set. A LinkedHashSet is similar, but it also superimposes a doubly-linked list on the elements to keep track of the insertion order.
Here is the code of HashMap
import java.util.*;
public class HashMapTest {
public static void main(String[] args) {
HashMap hash = new HashMap();
hash.put("Amardeep", new Double(3434.34));
hash.put("Vinod", new Double(123.22));
hash.put("suman", new Double(1200.34));
hash.put("Sandeep", new Double(99.34));
hash.put("Chandan", new Double(-150.34));
hash.put("Ravi", new Double(-100.34));
hash.put("Deepak", new Double(-115.34));
hash.put("Santosh", new Double(-200.34));
Set set = hash.entrySet();
Iterator iter = set.iterator();
while(iter.hasNext()){
Map.Entry me = (Map.Entry)iter.next();
System.out.println(me.getKey() + " : " + me.getValue() );
}
// deposit balence Amardeep account
double balance = ((Double)hash.get("Amardeep")).doubleValue();
hash.put("Amardeep", new Double(balance + 1000));
System.out.println("Amardeep new balance : " + hash.get("Amardeep"));
}
}
---------------------------------------
Visit for more information.
http://www.roseindia.net/java/example/java/util/Thanks.
Amardeep