String str1 = "abcdrstopq";
String str2 = "bcdlmnopqrst";
int len1 = str1.length();
int len2 = str2.length();
int j = 0;
int i = 0;
String result = "";
for(;i<len2;i++){
char tempc = str2.charAt(i);
// System.out.println(tempc);
j = str1.indexOf(tempc, i);
int k = j;
if(j > 0){
j++;
for(;j<len1;j++){
i++;
if(str1.charAt(j) != str2.charAt(i)){
break;
}
}
result = str1.substring(k, j);
list.add(result);
System.out.println(result);
}
}
String str2 = "bcdlmnopqrst";
int len1 = str1.length();
int len2 = str2.length();
int j = 0;
int i = 0;
String result = "";
for(;i<len2;i++){
char tempc = str2.charAt(i);
// System.out.println(tempc);
j = str1.indexOf(tempc, i);
int k = j;
if(j > 0){
j++;
for(;j<len1;j++){
i++;
if(str1.charAt(j) != str2.charAt(i)){
break;
}
}
result = str1.substring(k, j);
list.add(result);
System.out.println(result);
}
}