How to make user input case-insensitive in Java?

Great points, @ian-partridge For larger datasets, I’ve found using Java Streams with toLowerCase() incredibly efficient. It’s a modern, clean approach that makes filtering a breeze.

:white_check_mark: Use toLowerCase() in a Stream (Modern & Clean) When dealing with larger lists, Java Streams make the search operation concise and case-insensitive:

List<String> matchingPatients = myPatientList.getPatients().stream()  
    .filter(p -> p.toLowerCase().contains(name.toLowerCase()))  // Ignore case  
    .collect(Collectors.toList());  

System.out.println(matchingPatients);  

:point_right: Why this is great?

  • Efficient for large datasets — no need for manual loops.
  • Makes the code clean and readable.
  • Leverages the power of Streams for better performance.