I found a strange (at least for me) behavior in my small Java application. I have an app.jar which running from command line to do a simple task. The task is, find duplicate values from the given list and remove them. The application was developed with JDK-7 and running with JRE-7.
From command line of my PC everything is OK, but when running the same JAR in virtual machine which is Windows-7 as mine and with the same JRE it doesn’t remove duplicates and no any error occurs.
Here is my code:
public List<String> removeDuplicatedFin(List<String> coreList,
Map<String, String> strToRemoveMap) {
for (int y = 0; y < coreList.size(); y++) {
String str = coreList.get(y).getPosts().get(0).getMyStr();
String id = coreList.get(y).getPosts().get(0).getId();
if (strToRemoveMap.get(str) != null
&& strToRemoveMap.get(str).equals(idPost)) {
coreList.get(y).getPosts().remove(0);
}
}
return coreList;
}
coreList is the main list
strToRemoveMap contains values to be deleted
Any idea or some help please?
Thanks in advance