If you're using Java 8

List<String> list = new ArrayList<>();

boolean containsSearchStr = list.stream().anyMatch("search_value"::equalsIgnoreCase);
Answer from Nivas Mane-Patil on Stack Overflow
🌐
Websparrow
websparrow.org › home › check hashset contains element case insensitive in java
Check HashSet contains element case insensitive in Java - Websparrow
July 14, 2019 - package org.websparrow; import java.util.HashSet; import java.util.Iterator; import java.util.Set; public class HashSetContains { public static void main(String[] args) { Set<String> cars = new HashSet<>(); cars.add("Tata"); cars.add("mAHinDrA"); cars.add("BMW"); cars.add("Maruti Suzuki"); /** * Using Set contains method */ System.out.println(cars.contains("Tata")); // true System.out.println(cars.contains("TATA")); // false /** * Using Java 8 */ // matching equality -> Case sensitive boolean containsMyCar = cars.stream().anyMatch("Tata"::equals); System.out.println(containsMyCar); // true boo
🌐
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; } }
🌐
W3Schools
w3schools.com › java › ref_string_equalsignorecase.asp
Java String equalsIgnoreCase() Method
Java Examples Java Videos Java ...yStr1.equalsIgnoreCase(myStr3)); // false ... The equalsIgnoreCase() method compares two strings, ignoring lower case and upper case differences....
🌐
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.
🌐
Narkive
comp.lang.java.narkive.com › 0yxUEsKe › case-insensitive-collections-sets-maps-etc
Case-insensitive collections (sets, maps, etc.)
Either write your own loop, or ... the data first. Even if you wanted to preserve case for a Set, use HashMap<String,String> keyed on, say, the lowercase form, and mapping to the actual capitalisation....
🌐
Java Code Geeks
examples.javacodegeeks.com › home › java development › core java
Case Insensitive String Handling in Java Lists - Java Code Geeks
February 28, 2024 - If the loop completes without finding a match, the method returns false, indicating that the searchString is not present in the list. To verify whether the containsIgnoreCase() method works as expected, we test it in the main method of the Java ...
🌐
Educative
educative.io › answers › what-is-stringutilscontainsignorecase-in-java
What is StringUtils.containsIgnoreCase in Java?
containsIgnoreCase is a static method of the StringUtils class that checks whether a given string contains the complete search string as a whole, while ignoring the case considerations.
Find elsewhere
🌐
Javapedia
javapedia.net › Collections › 586
Does HashSet ignore String case when contains() method is invoked in Java?
HashSet's contains() method is case sensitive and does not allow the use of comparators. We could use TreeSet instead of HashSet which allow Comparator thus facilitating case-insensitive search and comparison. Using the comparator String.CASE_INSENSITIVE_ORDER we could perform case ignored search.
🌐
Talend
javadocs.restlet.talend.com › 2.4 › jse › engine › org › restlet › engine › util › CaseInsensitiveHashSet.html
CaseInsensitiveHashSet (Restlet Engine 2.4.3 - Java Standard Edition)
add in interface java.util.Set<java.lang.String> Overrides: add in class java.util.HashSet<java.lang.String> public boolean contains(java.lang.String element) Verify containment by ignoring case.
🌐
Java2Blog
java2blog.com › home › core java › string › java string contains ignore case
Java String contains Ignore Case - Java2Blog
August 26, 2021 - For example, The result is true ... is using a regex pattern to find matching strings. If we use a (?i) argument in the matches method, we make it case-insensitive....
🌐
Baeldung
baeldung.com › home › java › java string › case-insensitive string matching in java
Case-Insensitive String Matching in Java | Baeldung
August 28, 2025 - In this tutorial, we looked at a few different ways to check a String for a substring, while ignoring the case in Java. We looked at using String.toLowerCase() and toUpperCase(), String.matches(), String.regionMatches(), Apache Commons StringUtils.containsIgnoreCase(), and Pattern.matcher().find().
🌐
Coderanch
coderanch.com › t › 436898 › certification › ignore-case-Set
How to ignore case in Set ? (OCPJP forum at Coderanch)
But it doesn't actually restrict set to adding lowercase String. So its driver class dependent code actually. What you can do is, create one specialized String class, if its going to be used too frequently in your application. Then you can add instance of thi MyString class into set.
🌐
amitph
amitph.com › home › java › case-insensitive search in java arraylists
Case-Insensitive Search in Java ArrayLists - amitph
November 22, 2024 - public static boolean ... false; }Code language: Java (java) The method iterates over the given List and tries to match elements with the given text, ignoring the case....
🌐
TutorialsPoint
tutorialspoint.com › article › how-do-we-check-if-a-string-contains-a-substring-ignoring-case-in-java
How do we check if a String contains a substring (ignoring case) in Java?
September 1, 2025 - Java is designed to have as few implementation dependencies as possible."; String subStr = "welcome"; boolean result = str.toLowerCase().contains(subStr.toLowerCase()); if(result){ System.out.println("The string contains the substring."); }else{ System.out.println("The string does not contain the substring."); } } }
🌐
Coderanch
coderanch.com › t › 687154 › java › HashSet-case-insensitive
HashSet case insensitive (Java in General forum at Coderanch)
November 14, 2017 - You can use the class I wrote above, but then you must not let it implement the Set interface. It can extend AbstractCollection though. ... Carey Brown wrote:I was looking at Java's source code for equalsIgnoreCase() and they do an interesting thing, they compare the chars to see if they're equal, if not then they compare the lower case of the chars to see if they're equal.