There are simple ways that I can think of -
1. Split the string with the delimiter being the sub-string that you need to search for. You would get faulty result if your sub-string is overlapping each other. For ex-
String to search in - "theyforforfortheforforin"
Sub-string to search for - "forfor"
It depends on what your requirements are.
2. You can use regular expression to find the number of matching for a regex.
Read about it here -
Java Regex Documentation for Regex
I'm sure there are many more methods, explore!