I have a question about writing the if condition in a loop. Informally, I want the condition to work as follows. I will have a string, and I want to compare it against a list of strings. If it does not match any of the values in the list, then go ahead and execute the body of the if statement. If it does match one of the values, skip the body of the if statement. Here is my code (I wrote comments just be clear):
Iterator it=row.entrySet().iterator();
Iterator iter=getPrimaryKey.entrySet().iterator();
Map.Entry pairs=(Map.Entry)it.next();
if(!(pairs.getKey().equals(iter.next()))){ //this is the condition. I'm talking about. I want the key to run through all the membres of iter. If it is distinct from all of them, go ahead and execute the code in the if statement.
Anyways, I do not know what I’m doing wrong so I’d be interested in hearing suggestions.
It sounds to me like you want to check if a string in the “it” iterator is present as one of hte strings in the getPrimaryKey.entrySet(), so you might want to check directly if its contained there.