How can I convert a char to CharSequence?

I give you an example:

Syntax of String contains method

public boolean String.contains(CharSequence s)

Parameters

String “e” − This is the sequence to search

Return Value

This method returns true only if this string contains “e” else false.

Exception

NullPointerException − if the value of the parameter is null.

Example

String yourSentence = "Hello world";
char yourChar = yourSentence.charAt(1);
String anotherSentence "Hello everyone";
boolean result = anotherSentence.contains(String.valueOf(yourChar)));

Leave a Comment