标签:
import java.util.Scanner; public class GetCommonStr { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String str1 = scan.nextLine(); String str2 = scan.nextLine(); String result = getCommonStr(str1,str2); System.out.println(result); } private static String getCommonStr(String str1, String str2) { str1 = str1.toLowerCase(); str2 = str2.toLowerCase(); for (int i = 0; i < str2.length(); i++) { for (int j = 0,k = str2.length()-i; k != str2.length() + 1; j++,k++) { String temp = str2.substring(j, k); if(str1.contains(temp)) return temp; } } return null; } }
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/liaction/article/details/47789161