- public static String getMaxSubString(String s1,String s2){
-
- String max = null,min = null;//定义两个变量存储大小字符串
- max = (s1.length()>s2.length()) ? s1 : s2;
- min = max.equals(s1) ? s2 : s1;//分出两个字符串大小
-
- for(int x=0;x<min.length();x++){
-
- for(int y=0,z=min.length()-x;z<min.length()+1;y++,z++){
-
- String sub = min.substring(y,z);
- if(max.contains(sub));
- return sub;
- }
- }
-
- return null;
- }
复制代码 |
|