You have to use the String method .toLowerCase()
or .toUpperCase()
on both the input and the string you are trying to match it with.
Example:
public static void findPatient() { System.out.print("Enter part of the patient name: "); String name = sc.nextLine(); System.out.print(myPatientList.showPatients(name)); } //the other class ArrayList<String> patientList; public void showPatients(String name) { boolean match = false; for(String matchingname : patientList) { if (matchingname.toLowerCase().contains(name.toLowerCase())) { match = true; } } }
Related Posts:
- How do I lowercase a string in Python?
- string to string array conversion in java
- Convert character to ASCII numeric value in java
- How do I print my Java object without getting “SomeType@2f92e0f4”?
- Taking a new line using printf in java? Is %n correct?
- How to convert a string to lower or upper case in Ruby
- How do I convert a String to an int in Java?
- How to format strings in Java
- Java – Convert integer to string [duplicate]
- What is lexicographical order?
- How to split a string in Java
- How do I compare strings in Java?
- How to convert a char to a String?
- Regex not operator
- How to convert/parse from String to char in java?
- Reverse a string in Java
- working of \n in python [duplicate]
- Regex not operator
- Reverse a string in Java
- Extract a substring using PowerShell
- Java String Split by “|”
- Convert String to double in Java
- Java String new line
- Extract substring in Bash
- Regex not operator
- How to check if a String contains another String in a case insensitive manner in Java?
- Java split string to array [duplicate]
- String concatenation: concat() vs “+” operator
- How to remove the last character from a string?
- Java string to date conversion
- How to replace � in a string
- Change date format in a Java string
- What are all the escape characters?
- Converting String to “Character” array in Java
- What is the difference between \r\n, \r, and \n? [duplicate]
- What is the difference between \r\n, \r, and \n? [duplicate]
- Best way to convert an ArrayList to a string
- How can I prevent java.lang.NumberFormatException: For input string: “N/A”?
- Regex how to match an optional character
- How to remove punctuation in python?
- Best way to convert an ArrayList to a string
- How to split a String by space
- String variable interpolation Java [duplicate]
- String interpolation in Java 14 or 15
- How do I properly compare strings in C?
- How to remove .html from URL?
- What is the difference between a “line feed” and a “carriage return”?
- How to convert an int to string in C?
- How can I prevent java.lang.NumberFormatException: For input string: “N/A”?
- How to remove single character from a String
- Python: TypeError: cannot concatenate ‘str’ and ‘int’ objects
- How to parse this string in Java?
- How to convert any Object to String?
- How to replace all double quotes to single quotes using jquery?
- How to split a string in Java
- How to replace ” \ ” with ” \\ ” in java
- What does strcmp() exactly return in C?
- Generate random string/characters in JavaScript
- Illegal Escape Character “\”
- Can I multiply strings in Java to repeat sequences?
- “[ ]” vs. “[[ ]]” in Bash shell
- What does regular expression \\s*,\\s* do?
- How to trim whitespace from a Bash variable?
- How can I remove punctuation from input text in Java?
- How to convert a Binary String to a base 10 integer in Java
- Left Hand Side of an Assignment must be a Variable CharAt
- How to capitalize the first letter of a String in Java?
- How to get the filename without the extension from a path in Python?
- sprintf like functionality in Python
- catDog string problem at Codingbat.com
- Java way to check if a string is palindrome
- Return string Input with parse.string
- What is the difference between String.subString() and String.subSequence()
- How do I apply the for-each loop to every character in a String?
- Java – removing first character of a string
- C – The %x format specifier
- Java compressing Strings
- Lua string.format options
- In Java, how to append a string more efficiently?
- n-grams in python, four, five, six grams?
- Explain the use of a bit vector for determining if all characters are unique
- Explain the use of a bit vector for determining if all characters are unique
- Convert java.util.Date to String
- Convert array of strings into a string in Java
- Alphabet range in Python
- How do I lowercase a string in C?
- How can I remove punctuation from input text in Java?
- Sort a single String in Java
- How to remove single character from a String
- How to remove single character from a String
- What is Java String interning?
- What is Java String interning?
- What is Java String interning?
- Why is there no String.Empty in Java?
- Java split string to array
- How to trim whitespace from a Bash variable?
- Using Enum values as String literals
- What is the easiest/best/most correct way to iterate through the characters of a string in Java?
- What is the difference between ‘ and ” in JavaScript?
- Center text in fixed-width field with stream manipulators in C++