ArrayList contains case sensitivity

You can use this exactly like you’d use any other ArrayList. You can pass this List out to other code, and external code won’t have to understand any string wrapper classes.

public class CustomStringList3 extends ArrayList<String> {
    @Override
    public boolean contains(Object o) {
        String paramStr = (String)o;
        for (String s : this) {
            if (paramStr.equalsIgnoreCase(s)) return true;
        }
        return false;
    }
}

Leave a Comment