Blog from an ATG Developer

June 24, 2009

Deleting items in a Map

Filed under: Java — madhulal @ 10:47 am
Tags: , ,

Suppose we want to delete some items from a map based on indices, which is passed as an array. We can’t delete them by iterating through the array, because each time when we delete an item, the hash map shrinks by one. So the new index will be different from what we expect. We can use the following code to perform the operation without any delays.

public void deleteItemFromMap(String[] indexArray){
List beanList = getMap();
MyBean myBean = null;

int index = 0;
int newIndex;

if(indexArray!=null){
for (String indexString : indexArray) {
newIndex = Integer.parseInt(indexString) – index;
myBean = beanList.remove(newIndex);
if(null != myBean){
index = index + 1;
}
}
}

}

June 8, 2009

A very good Java Decompiler

Filed under: Decompiler, Eclipse, Java — madhulal @ 12:25 pm
Tags: ,

JD|Java Decompiler is one of the best decompiler I have used. Visit them here.

This can be used as a stand alone application as well as an eclipse plugin. This works like achieve application in case of of jar files.
The site url to be used is http://java.decompiler.free.fr/jd-eclipse/update

Need help in installing it in MyEclipse?. Download the word(docx) file here.

Give it a shot.

Blog at WordPress.com.