I currently have a String Array
String[] properSequence = ability.getSequence();
And I want to compare it to an ArrayList
ArrayList<String> sequence
As of right now I'm doing,
boolean matchesSequence = true;
String[] properSequence = ability.getSequence();
int index = 0;
for(String s : sequence) {
String s1 = properSequence[index];
if(!s1.equalsIgnoreCase(s)) {
matchesSequence = false;
break;
}
index++;
}
if(matchesSequence) {
// Matches, code
}
I was wondering if there's an easier/prettier way of doing this, seems a bit redundant.
if(!properSequence[i].toLowerCase().equals(sequence.get(i).toLowerCase())) return falseor something along those lines. Even better, use Apache StringUtils, which will take care of null safety for ya.private boolean compareList(Iterator a, Iterator b).