package com.itcast.base;
public class substringtest {
public static void main(string[] args) {
string str1 = "ashfjeudccckfjgiccccccjgurhd";
string str2 = "dhfurjcccckgoymjdhccfi";
string max = "";
for (int i = 0; i < str2.length(); i++) {
string temp1 = str2.substring(i);
// system.out.println("temp1:" + temp1);
for (int j = temp1.length() - 1; j >= 0; j--) {
string temp2 = temp1.substring(0, j);
// system.out.println("temp2:" + temp2);
if (str1.indexof(temp2) != -1 && temp2.length() > max.length()) {
max = temp2;
}
}
}
system.out.println("max:" + max);
}
}