Common string calculations

Source: Internet
Author: User
Import Java.util.arrays;import Java.util.scanner;public class Getcommonstring {public static void main (string[] args) { Scanner scan = new Scanner (; String str1 = (). toLowerCase (); String str2 = (). 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.