public static String getMaxSubString(String s1,String s2)
{
for(int x=0;x<s2.length();x++)
{
for(int a=0,b=s2.length()-x;b!=s2.length()+1;a++,b++)
{
String temp=s2.substring(a, b);
if(s1.indexOf(temp)!=-1)
return temp;
}
}
return "";
}
public class StringMethodDemo
{
public static void main (String[] args)
{
String s1="abchelloabc";
String s2="aaahellob";
sop(getMaxSubString(s1, s2));
}
第一个方法里面一个return就不对
|