/*
找到两个字符串中的最大相同子串
*/
class StrMax
{
public static void main(String[] args)
{
String s1="adsfhellowordsdsadfacjuejx";
String s2="acsdfhellowsds";
String s3="1a2543";
System.out.println(Finder.find(s1,s2));
}
}
class Finder
{
public static final String find(String str,String key)
{
int length=key.length();
String s="";
for (int i=0;i<length;i++ )
{
for (int j=0;j<=i ;j++ )
{
s=key.substring(j,length-i+j);
if (str.contains(s))
{
return s;
}
}
}
return "没有";
}
} |
|