You can use string.indexOf('a').

If the char a is present in string :

it returns the the index of the first occurrence of the character in the character sequence represented by this object, or -1 if the character does not occur.

Answer from mP. on Stack Overflow
Discussions

JAVA - String contains char letter. Possible to check? - Stack Overflow
I am trying to make a method called Baller(String str, char chr) which should return a boolean if the word contains the character. In the main method I have: public static void main(String[] args... More on stackoverflow.com
🌐 stackoverflow.com
file - How to see if a string contains a specific char in Java? - Stack Overflow
I'm trying to see if a string contains a specific character in it. For example, given the text file: I am going to the store. I will be at . I need to buy . I'm trying to ... More on stackoverflow.com
🌐 stackoverflow.com
Java why i cant check if string contains char?
i can do if(test[x].contains(“char”); “char” is a String, not a char. Contains presumably expects a string. If you try to call it with a char, it will fail. Edit: actually it expects a CharSequence. String implements CharSequence, but char does not. More on reddit.com
🌐 r/learnprogramming
3
2
March 30, 2019
How to check for invalid characters in a string?
Something like this would work. $String = 'abc123_DEF(-&%' if ($String -match '[^a-zA-Z0-9.+_-]'){ $Message = "'{0}' contains illegal character '{1}'." -f $String,$Matches[0] $Exception = [System.FormatException]::new() Write-Error -Exception $Exception -Message $Message } More on reddit.com
🌐 r/PowerShell
8
3
December 29, 2016
🌐
TechVidvan
techvidvan.com › tutorials › java-string-contains-method
Java String contains() Method - TechVidvan
March 4, 2024 - One such method is called the contains(), which allows you to find out if a string has a sequence of characters. For more information, the contains() method is a built-in Java method to check that strings contain any special character or sequence of characters.
🌐
Tutorialspoint
tutorialspoint.com › java › lang › string_contains.htm
Java - String contains() Method
The Java String contains() method is used to check whether the current string contains the specified sequence. It returns the Boolean value, which is true if and only if the string contains the sequence of char values; false otherwise.
🌐
Delft Stack
delftstack.com › "delft stack" › "howto" › "java howtos" › "how to check if a string contains character in java"
How to Check if a String Contains Character in Java | Delft Stack
February 2, 2024 - The enhanced for loop is employed to iterate through each character in the string. For each iteration, the loop compares the current character (c) with the target character (targetChar). If a match is found, containsChar is set to true, and the loop is terminated using the break statement. After the loop completes, a conditional check is performed based on the value of containsChar, and a corresponding message is printed. Java Streams were introduced in Java 8 to facilitate functional-style programming on collections of elements.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-string-contains-method-example
Java String contains() Method with Example - GeeksforGeeks
July 11, 2025 - The String.contains() method is used to search for a sequence of characters within a string. In this article, we will learn how to effectively use the string contains functionality in Java.
Find elsewhere
🌐
Sabe
sabe.io › blog › java-check-string-contains-character
How to Check if a String Contains a Character in Java - Sabe.io
May 25, 2022 - Another way to check if a string contains a character is to use the indexOf() method on the String class. This method takes in a string as a parameter and returns the index of the first occurrence of that string in the string.
🌐
Baeldung
baeldung.com › home › java › java string › java string.contains()
Java String.contains() | Baeldung
April 11, 2025 - • Java String.contains() (current ... String.toUpperCase() • Java String.trim() • Java String.valueOf() The method contains() checks if a String contains another String....
🌐
ISA-Ali
alias-i.com › home › java string contains char: methods for character search
Check if Java String Contains Char - String Char Search
August 18, 2023 - To determine whether a Java string includes a certain character, you can utilize the following techniques: – The contains() method of the Java String class examines if a specific sequence of characters exists within the string.
🌐
BeginnersBook
beginnersbook.com › 2017 › 10 › java-string-contains-method
Java String contains() method
June 10, 2024 - Java String contains() method checks whether a particular sequence of characters is part of a given string or not.
🌐
iO Flood
ioflood.com › blog › java-string-contains
Java String Contains(): A Detailed Usage Guide
February 26, 2024 - However, it’s important to remember that the ‘contains’ method is case-sensitive. This means that ‘Java’ and ‘java’ would be considered different sequences. While the ‘contains’ method is a powerful tool for checking if a string contains a certain sequence of characters, Java offers other methods that can achieve the same goal.
🌐
Medium
medium.com › @AlexanderObregon › checking-if-a-string-contains-a-word-or-phrase-in-java-08ef51495d87
Checking if a String Contains a Word or Phrase in Java
June 16, 2025 - That makes it a bit more flexible than contains, especially when you're dealing with structured or repeated data. matches takes a different path. It’s not doing simple character comparison. It’s using the regular expression engine built into Java. That means it sees your input as a pattern, not just text. But there’s a catch. matches checks if the entire string fits the pattern, not just part of it.
Top answer
1 of 2
1

char is not CharSequence

Your call to String::contains takes a CharSequence such as String while you are passing a char. Two different types.

Use the double-quote mark rather than single-quote mark around < to get a String object rather than a char primitive: "<" versus '<'.

boolean containsLessThan = input.contains( "<" ) ;

If your goal is simply deletion of such characters, use String::replace.

String result = input.replace( "<" , "" ).replace( ">" , "") ;

FYI, the char type is obsolete, unable to represent even half of the characters defined in Unicode.

Here is a chart I created showing the various text-related classes bundled with Java. String is one of several classes that implement the CharSequence interface. The char type is not included here because it is (a) a primitive rather than a class, and (b) obsolete.

By the way, recommended reading: The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)

2 of 2
0

You can use info.indexOf('<')

it returns the the index of the first occurrence of the character in the character sequence represented by this object, or -1 if the character does not occur.

So this would be your code: if(info.indexOf('<') > -1)

Strong Recommendation: Please first search enough and/or read the right documentation for each part of the code that you're working with or each time get stuck. Asking question would be the last choice when you absolutely devistated. Here is exactly what you asked for example:

https://stackoverflow.com/questions/506105/how-can-i-check-if-a-single-character-appears-in-a-string#:~:text=You%20can%20use%20string.,the%20character%20does%20not%20occur.

🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › String.html
String (Java Platform SE 8 )
July 21, 2026 - Allocates a new string that contains the sequence of characters currently contained in the string builder argument.
🌐
CodeGym
codegym.cc › java blog › strings in java › java string contains() method
Java String contains() Method
January 8, 2025 - java.lang.String provides a boolean method contains() that returns ‘true’ if a sequence of characters is found within the given string and ‘false’ otherwise
🌐
Guru99
guru99.com › home › java tutorials › java string contains(): check if string contains substring
Java String contains(): Check if String contains Substring
October 1, 2026 - Java String contains() method checks whether a specified sequence of characters exists within a given string, returning a boolean true or false.
🌐
YouTube
youtube.com › dan vega
Quick Java Tip: How to Use the String.contains Method in Just 60 Seconds! 💡 - YouTube
The String class in Java has a contains method which will search for a sequence of characters and return true if they were found. 👋🏻Connect with me:Website...
Published: April 21, 2023
Views: 20K
🌐
GeeksforGeeks
geeksforgeeks.org › java › searching-for-characters-and-substring-in-a-string-in-java
Searching For Characters and Substring in a String in Java - GeeksforGeeks
July 23, 2025 - Note: CharSequence is an interface that is implemented by String class, Therefore we use string as an argument in contains() method.