Java Char Array Match charArrayRegionMatches(char[] value, int startPos, CharSequence toMatch)

Here you can find the source of charArrayRegionMatches(char[] value, int startPos, CharSequence toMatch)

Description

char Array Region Matches

License

Apache License

Declaration

public static boolean charArrayRegionMatches(char[] value, int startPos, CharSequence toMatch) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static boolean charArrayRegionMatches(char[] value, int startPos, CharSequence toMatch) {
        int matchLen = toMatch.length(), endPos = startPos + matchLen;

        if (endPos > value.length) {
            return false;
        }// w ww. jav  a  2  s.  c  o  m

        for (int matchIndex = 0, i = startPos; i < endPos; i++, matchIndex++) {
            if (value[i] != toMatch.charAt(matchIndex)) {
                return false;
            }
        }

        return true;
    }
}