That is already in the String class:
String word = "cat";
String text = "The cat is on the table";
Boolean found;
found = text.contains(word);
That is already in the String class:
String word = "cat";
String text = "The cat is on the table";
Boolean found;
found = text.contains(word);