I am coding in Java and I understand well that I can compare most arrays with Arrays.equals
, and I can compare strings case insensitively with String.equalsIgnoreCase
, but is there a way to specifically compare Arrays of strings case insensitively?
sample code:
class Foo {
String[] array; // don't care about case
@Override
public boolean equals(Foo obj) {
// bunch of stuff to check equality
if (!Arrays.equals(array, obj.array)) return false; // case insensitive?
return true;
}
}
Your code wont compile as you are not overriding the Object's equals method which has signature like
public boolean equals(Object obj)
Also to do comparison, you could do the following in your modified equals as below: