Since years I’m wondering why there is no method containsIgnoreCase in the class String. We have equals and equalsIgnoreCase, but there is only contains and no containsIgnoreCase. Is there a reason for that?
Since years I’m wondering why there is no method containsIgnoreCase in the class String
Share
It’s really impossible to say what the exact reason was. Perhaps it was felt that
equalswould be used more frequently thancontainsand so it would prove most useful to implement anequalsIgnoreCasemethod, but not all that useful to implementcontainsIgnoreCase. In any case, it’s hard to be sure. Having said that, you can indeed easily implement your own method in terms of the originalcontainsmethod, something along these lines could work: