package test;
public class substring {
public static void main(String[] args) {
// TODO Auto-generated method stub
String str = "helloslkhellodjladfjhello";
String findStr = "hello";
int lastIndex = 0;
int count = 0;
while (lastIndex != -1) {
System.out.println("first "+lastIndex);
if (lastIndex != -1) {
count++;
lastIndex += findStr.length();
}
}
System.out.println("number of substring"+count);
}
}
public class substring {
public static void main(String[] args) {
// TODO Auto-generated method stub
String str = "helloslkhellodjladfjhello";
String findStr = "hello";
int lastIndex = 0;
int count = 0;
while (lastIndex != -1) {
System.out.println("first "+lastIndex);
if (lastIndex != -1) {
count++;
lastIndex += findStr.length();
}
}
System.out.println("number of substring"+count);
}
}