That is already in the String class:
String word = "cat";
String text = "The cat is on the table";
Boolean found;
found = text.contains(word);
More Related Contents:
- Need some advice on split() method in Java [closed]
- StringBuilder vs String concatenation in toString() in Java
- Sort on a string that may contain a number
- Check if String contains only letters
- Check string for palindrome
- length and length() in Java
- How to format a Java string with leading zero?
- Is String Literal Pool a collection of references to the String Object, Or a collection of Objects
- Convert array of strings into a string in Java
- How to insert a character in a string at a certain position?
- Understanding logic in CaseInsensitiveComparator
- How to shuffle characters in a string without using Collections.shuffle(…)?
- Closing a Scanner throws java.util.NoSuchElementException
- The most sophisticated way for creating comma-separated Strings from a Collection/Array/List?
- Which loop has better performance? Why?
- Is conversion to String using (“” + ) bad practice?
- Convert binary string to byte array
- What is the best way to extract the first word from a string in Java?
- How to replace ” \ ” with ” \\ ” in java
- Print out elements from an Array with a Comma between the elements
- Java split is eating my characters
- How to prevent java.lang.String.split() from creating a leading empty string?
- Java. Ignore accents when comparing strings
- Efficient way to compare version strings in Java [duplicate]
- Case insensitive matching in Java switch-case statement
- What is the most efficient way to convert an int to a String?
- String.replaceAll is considerably slower than doing the job yourself
- Remove all occurrences of \ from string
- How to convert hex string to float in Java?
- Java: Checking equality of arrays (order doesn’t matter)