I want the contains() method from ArrayList to be case insensitive.
Is there any way?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No. You will have to define your own contains method that will have to iterate among the
ArrayListand compare the values using theequalsIgnoreCasemethod of theStringclass.Edit: I don’t want to be rude, but the question is pretty clear: the guy wants to use the
containsmethod. So he can’t/should usetoLowerCasebefore adding the elements because of too many reasons: for example, he could need the originalString(not the one that is lowercased). Also, as we are talking about thecontainsmethod, we are focusing on the elements rather than their indexes (as someone answered some minutes ago).