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
🌐
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 - Conversely, if the result is false, indicating the absence of the character, a different message is printed. It’s essential to note that the contains() method in Java is case-sensitive.
Discussions

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
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 - How can I find out if a string contanis a char? - Stack Overflow
Is there any way to check to see if a string contains a char? Like create an if statement that will check a string to see if has a certain char in it but the char is a variable that is user inputted? More on stackoverflow.com
🌐 stackoverflow.com
🌐
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 - In this post, we'll look at examples of the two best ways to search for a character in a string in Java. The easiest way to check if a string contains another character is to use the contains() method on the String class.
🌐
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.
Find elsewhere
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.

🌐
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
🌐
Reddit
reddit.com › r/learnjava › how do i check if a string contains a letter?
How do I check if a string contains a letter? : r/learnjava
March 22, 2024 - So you can invert this using ! to check if it contains some non digit character. ... private List<String> errors(String s) { if(s == null) { return List.of("Input is null, this is never supposed to happen"); } if(s.isBlank()) { return List.of("Input is blank, cannot math on this"); } // And now we can go through the whole string, char for char.
🌐
TechVidvan
techvidvan.com › tutorials › java-string-contains-method
Java String contains() Method - TechVidvan
March 4, 2024 - The contain() method checks to see if a character sequence is present in the string. If the characters exist and if they don’t, returns true. Syntax: public boolean contains(CharSequence chars) In Java’s string data type, a variety of methods are available to manage and manipulate the text ...
🌐
BeginnersBook
beginnersbook.com › 2017 › 10 › java-string-contains-method
Java String contains() method
June 10, 2024 - String str = "Game of Thrones"; //This will print "true" because "Game" is present in the given String System.out.println(str.contains("Game")); // This will print "false" because "aGme" is not present, the characters // must be present in the same sequence as specified in the contains method System.out.println(str.contains("aGme"));
🌐
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.
🌐
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.
🌐
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 - ✅ What does the contains() method return in Java? The contains() method returns a boolean value: true if the specified CharSequence is found within the string, and false otherwise.
🌐
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.
🌐
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....