How do you check if a string contains a substring?

You can use contains(), indexOf() and lastIndexOf() method to check if one String contains another String in Java or not. If a String contains another String then it’s known as a substring. The indexOf() method accepts a String and returns the starting position of the string if it exists, otherwise, it will return -1.

Sizin İçin Seçtik  How do you use case sensitive in Java?

Leave a Reply

Your email address will not be published. Required fields are marked *