
i want to know use of Hashmap, and its contains key value option. the problem is , i am accessing records through a loop but I want to access only those records that has unique id. I dont want to use sameid record more than one time. so could u please guide me how to handle this problem.
through this id i m creating a shape node so multiple nodes are build even they have same id so i want to stop repetition.

import java.util.*;
public class HashMapExample{
public static void main(String[] args) {
HashMap hm = new HashMap();
hm.put(1,"A");
hm.put(2,"B");
hm.put(1,"C");
hm.put(3,"D");
hm.put(4,"E");
Set set = hm.entrySet();
Iterator i = set.iterator();
while(i.hasNext()){
Map.Entry me = (Map.Entry)i.next();
System.out.println(me.getKey() + " : " + me.getValue() );
}
}
}