java contains 大小写,使用.contains方法忽略大小写的选项?

Is there an option to ignore case with .contains() method?

I have an ArrayList of DVD object. Each DVD object has a few elements, one of them is a title. And I have a method that searches for a specific title. It works, but I'd like it to be case insensitive.

解决方案

I'm guessing you mean ignoring case when searching in a string?

I don't know any, but you could try to convert the string to search into either to lower or to upper case, then search.

// s is the String to search into, and seq the sequence you are searching for.

bool doesContain = s.toLowerCase().contains(seq);

Edit:

As Ryan Schipper suggested, you can also (and probably would be better off) do seq.toLowerCase(), depending on your situation.