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);
}
}