Reputation: 11
enter image description hereI have a hashmap which I need to compare values of the String array to certain strings and remove those which are equal. In this instance I know the String [] at a certain index = "RES", but when I iterate through the if (equality) statement returns false each time. Do I have to worry about overriding .equals() when simply extending hashmap? What is wrong with the if statement?
public void filter(){
Iterator<Map.Entry<String, String[]>> iter = this.entrySet().iterator();
while(iter.hasNext()){
Map.Entry<String,String[]> entry = iter.next();
String[] current = entry.getValue();
if(current[0].trim().equalsIgnoreCase("RES")){
this.remove(entry.getKey());
}
}
}
Upvotes: 0
Views: 68