0 votes
1 view
in Java by (10.2k points)

In Java is there a way to check the condition:

"Does this single character appear at all in string x"

without using a loop?

1 Answer

0 votes
by (46.1k points)

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

If the 'a' is present in string, it returns the index(>=0). If not, it returns -1. So, a non-negative return value means that 'a' is present in the string.

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...