Why is the following algorithm not halting for me? (str is the string I am searching in, findStr is the string I am trying to find)
String str = \"helloslkhe
As @Mr_and_Mrs_D suggested:
String haystack = "hellolovelyworld"; String needle = "lo"; return haystack.split(Pattern.quote(needle), -1).length - 1;