Android CharSequence Search findCommonSuffixLength(CharSequence str1, CharSequence str2, int commonPrefixLength)

Here you can find the source of findCommonSuffixLength(CharSequence str1, CharSequence str2, int commonPrefixLength)

Description

find Common Suffix Length

Declaration

private static int findCommonSuffixLength(CharSequence str1,
            CharSequence str2, int commonPrefixLength) 

Method Source Code

//package com.java2s;

public class Main {
    private static int findCommonSuffixLength(CharSequence str1,
            CharSequence str2, int commonPrefixLength) {
        int length = (Math.min(str1.length(), str2.length()));
        for (int i = 0; i < length - commonPrefixLength; i++) {
            if (str1.charAt(str1.length() - i - 1) != str2.charAt(str2
                    .length() - i - 1)) {
                return i;
            }/*  w ww  .ja  va 2  s . co  m*/
        }

        return 0;
    }
}

Related

  1. findCommonPrefixLength(CharSequence str1, CharSequence str2)
  2. indexOfDifference(CharSequence cs1, CharSequence cs2)