How to search a string in another string? [duplicate]

That is already in the String class:

String word = "cat";
String text = "The cat is on the table";
Boolean found;

found = text.contains(word);

Leave a Comment