How do you check if a string contains a specific substring in Java?
To check if a string contains a substring, you can use the indexOf() method. If the result is not -1, it means the substring is present.
You're close! While indexOf() can also be used, .contains() is a more direct way to check for a substring.
Can you show how the .indexOf() method works when the substring is not found in the string?