Import Java.util.arrays;import Java.util.scanner;public class Getcommonstring {public static void main (string[] args) { Scanner scan = new Scanner (system.in); String str1 = Scan.next (). toLowerCase (); String str2 = Scan.next (). toLowerCase (); if (Str1.length () < Str2.length ()) Getlen (STR1,STR2); Elsegetlen (str2, STR1) ;} private static void Getlen (String str1, String str2) {int [] a = new int[str2.length ()]; Arrays.fill (A, 0); for (int i = 0; i < str2.length (); i++) {for (int j = 0, J < Str1.length (); j + +) {if (Str2.charat (i ) ==str1.charat (j)) A[i]=1;}} StringBuffer sb = new StringBuffer (); for (int i = 0; i < a.length; i++) {sb.append (a[i]);} String s = sb.tostring (); String[] result = S.split ("0"); int max = 0;for (int i = 0; i < result.length; i++) {if (Result[i].length () > Max) max = Result[i].length ();} SYSTEM.OUT.PRINTLN (max);}}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Common string calculations