次奥...终于弄白咋回事了...NND...今天是肿么了..老是短路..
代码调试完毕,求筒子们更优化的代码,求交流~~~
public static String sameString_2(String str1,String str2)
{
int num = 0;
String temp ="";
for(int x = 0;x<str2.length();x++)
{
for(int y=str2.length();y>x;y--)
{
String str = str2.substring(x,y);
if(str1.contains(str)&&str.length()>num)
{
num = str.length();
temp = str;
}
}
}
return temp;
} |