নীচের অ্যালগরিদমটি আমার জন্য কেন থামছে না? (স্ট্রিংটি আমি অনুসন্ধান করছি এমন স্ট্রিং, ফাইন্ডএসআরটি হ'ল স্ট্রিংটি আমি সন্ধান করার চেষ্টা করছি)
String str = "helloslkhellodjladfjhello";
String findStr = "hello";
int lastIndex = 0;
int count = 0;
while (lastIndex != -1) {
lastIndex = str.indexOf(findStr,lastIndex);
if( lastIndex != -1)
count++;
lastIndex += findStr.length();
}
System.out.println(count);