contains just check if an object is present in the List. So you can't do a case insensitive lookup here, because "three" is a different object than "Three".

A simple approach to solve this would be

public boolean containsCaseInsensitive(String s, List<String> l){
     for (String string : l){
        if (string.equalsIgnoreCase(s)){
            return true;
         }
     }
    return false;
  }

and then

containsCaseInsensitive("three", data);

Java 8+ version:

public boolean containsCaseInsensitive(String s, List<String> l){
        return l.stream().anyMatch(x -> x.equalsIgnoreCase(s));
    }
Answer from Averroes on Stack Overflow
🌐
Baeldung
baeldung.com › home › java › java string › case-insensitive searching in arraylist
Case-Insensitive Searching in ArrayList | Baeldung
March 7, 2025 - If this is the case, we probably want to create a particular ArrayList<String> type, which supports the case-insensitive contains() method natively. So next, let’s create a subclass of ArrayList<String>: public class IgnoreCaseStringList extends ArrayList<String> { public IgnoreCaseStringList() { } public IgnoreCaseStringList(Collection<? extends String> c) { super(c); } @Override public boolean contains(Object o) { String searchStr = (String) o; for (String s : this) { if (searchStr.equalsIgnoreCase(s)) { return true; } } return false; } }
Discussions

java - Option to ignore case with .contains method? - Stack Overflow
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 sp... More on stackoverflow.com
🌐 stackoverflow.com
July 18, 2016
java - Checking if an ArrayList contains a certain String while being case insensitive - Stack Overflow
How can i search through an ArrayList using the .contains method while being case insensitive? I've tried .containsIgnoreCase but found out that the IgnoreCase method only works for Strings. More on stackoverflow.com
🌐 stackoverflow.com
December 12, 2016
java - ArrayList contains case sensitivity - Stack Overflow
Would compare two different sets ignoring case and return true, in this particular situation and your comparision would work without any issue. ... Looking at the Java API, there is no such method for contains. ... Write your own contains method, which should iterate through your ArrayList ... More on stackoverflow.com
🌐 stackoverflow.com
August 3, 2016
java - arraylist check if element exits here ignore the case - Stack Overflow
Hi i have the arraylist it stores the string values. I want to check the some string is exists in the list or not. Here i want ignore the case sensitive. code public static ArrayList More on stackoverflow.com
🌐 stackoverflow.com
August 31, 2012
🌐
Reddit
reddit.com › r/javahelp › how to ignore case when comparing arraylist elements to string ?
r/javahelp on Reddit: How To Ignore Case When Comparing ArrayList Elements To String ?
December 9, 2022 -
import java.util.ArrayList;

public class WordsCounter {

    public static int occurences(String string, ArrayList<String> words){
        int number = 0;
        for(int i = 0; i < words.size(); i++){
            if(words.get(i).equalsIgnoreCase(string)){
                number++;
            }
        }
        return number;
    }
}

I want to make a method that takes a string and a list of words as parameters, and returns how many of the words in the list could be found in the string at least once. It doesn't have to be the word exactly, just that a part of the string matches, like such:

If the String was "Sunshine is nice", and the list elements were "shine" and "nice", it would return 2.

I can't get it to work with the ignore of case, the program doesn't ignore case despite the method I used. I looked up String methods and equalsIgnoreCase seemed to be a good one but it does not work. I don't know if it's because it can't be applied to list elements (although they are Strings). Do any of you know how I should think regarding this?

🌐
amitph
amitph.com › home › java › case-insensitive search in java arraylists
Case-Insensitive Search in Java ArrayLists - amitph
November 22, 2024 - By default, the contains() method uses equals(), making the text searches case-sensitive. However, we can use classic Java to Streams API to create a static utility method to find an element in a Java List in ignoring the case.
🌐
Java2Blog
java2blog.com › home › core java › string › java string contains ignore case
Java String contains Ignore Case - Java2Blog
August 26, 2021 - The output is again true because we check if Albert exists in the String in a case-insensitive manner. ... IF we do the same operation but do not pass the (?i) parameter, we will get False. ... The apache foundation provides the apache-commons-lang jar. This jar contains a collection of utility classes, one of which is the StringUtils class.
🌐
Java2s
java2s.com › example › java-utility-method › array-contain › arraycontainsonlyignorecase-string-array-string...-strs-6d536.html
Java Array Contain arrayContainsOnlyIgnoreCase(String[] array, String... strs)
* @param array The String array to search with * @param str The String to search for * @return true if the String array contains the given String, case insensitive; false otherwise. */ public static boolean arrayContainsIgnoreCase(String[] array, String str) { if (array.length == 0) { return ...
Find elsewhere
🌐
Java Code Geeks
examples.javacodegeeks.com › home › java development › core java
Case Insensitive String Handling in Java Lists - Java Code Geeks
February 28, 2024 - The result of anyMatch is returned, which is true if at least one element in the list matches the given element (ignoring case), otherwise false. In Java, checking if a list contains a string element while ignoring case can be accomplished using various techniques.
🌐
Baeldung
baeldung.com › home › java › java list › check if a list contains a string element while ignoring case
Check if a List Contains a String Element While Ignoring Case | Baeldung
March 7, 2025 - Sometimes, we want to case-insensitively check if a string is an element in a string list. In this quick tutorial, we’ll explore various methods and strategies to solve this common problem in Java. List provides the convenient contains() method to check if a given value exists in the list.
🌐
Roy Tutorials
roytuts.com › home › java › searching an element in java arraylist
Searching an element in Java ArrayList - Roy Tutorials
September 27, 2016 - "found" : "not found")); found = list.contains("B"); System.out.println("element B : " + (found ? "found" : "not found")); int index = list.indexOf("c"); System.out.println("element c : " + (index <= 0 ? "not found" : "found")); index = list.indexOf("C"); System.out.println("element C : " + (index <= 0 ? "not found" : "found")); } } ... package com.roytuts.java.arraylist; import java.util.ArrayList; import java.util.List; public class SearchInArrayListCaseInsensitive { private boolean contains(String str, List<String> list) { for (String s : list) { if (str.equalsIgnoreCase(s)) return true; }
🌐
Delft Stack
delftstack.com › home › howto › java › string contains a substring in java
How to Check if String Contains a Case Insensitive Substring in Java | Delft Stack
February 2, 2024 - In this example, we used the Pattern class and its compile(), matcher(), and find() methods to check whether a string contains a substring or not. We used CASE_INSENSITIVE, which returns a boolean value, either true or false. See the example below. import java.util.regex.Pattern; public class SimpleTesting { public static void main(String[] args) { String str = "DelftStack"; String strToFind = "St"; System.out.println(str); boolean ispresent = Pattern.compile(Pattern.quote(strToFind), Pattern.CASE_INSENSITIVE).matcher(str).find(); if (ispresent) System.out.println("String is present"); else System.out.println("String not found"); } }
🌐
Java-forums
java-forums.org › new-java › 45805-how-use-contains-without-case-sensitivity.html
How to use Contains - without case sensitivity?
June 27, 2011 - Then you need an associated HashMap with the Uppercase name as key and the value being an ArrayList of all the different values that have different cases. Match first on the Uppercase and then search the arraylist for the case sensitive match. ... Hi Norm, My constraint concept was "Ignore Case - they're all the same"...
🌐
Tpoint Tech
tpointtech.com › containsignorecase-method-in-java
containsIgnoreCase() Method in Java - Tpoint Tech
March 17, 2025 - There are various scenarios where we need to consider case sensitivity.
🌐
Overclock.net
overclock.net › home › forums › software, programming and coding › coding and programming
Java List.Contains -- Case Insensitive? | Overclock.net
June 20, 2008 - Is there a way to use List.Contains(var) in case-insensitive form? E.g. if the list had "LyokoHaCk" and I plugged in "lyokohack" for the variable, it would still return true. I've tried iterating this and converting it to a string array then looping, but no luck! Thanks for the help!