public static boolean commonSuffixOfLength(String s, String p, int len) {
        return s != null && p != null && len >= 0 && s.regionMatches(s.length() - len, p, p.length() - len, len);
    }
public static boolean commonSuffixOfLength ( String s , String p , int len ) { return s != null && p != null && len >= 0 && s . regionMatches ( s . length ( ) - len , p , p . length ( ) - len , len ) ; }
Checks if two strings have the same suffix of specified length

@param s   string
@param p   string
@param len length of the common suffix
@return true if both s and p are not null and both have the same suffix. Otherwise - false