Friday, October 9, 2009

Removing Duplicates from HashMap

HashMap hashMap=new HashMap();
boolean flag;
for(int i=0;i< correspondenceActivityBeans.length ;i++){
flag=false;
if(!hashMap.containsKey(new Integer(correspondenceActivityBeans[i].getClientID()))){
hashMap.put(new Integer(correspondenceActivityBeans[i].getClientID()),correspondenceActivityBeans[i]);
flag=true;
}
if(flag)
tempList.add(correspondenceActivityBeans[i]);

}

No comments:

Post a Comment