boolean (char @NotNull [] buffer1, int start1, int end1, char @NotNull [] buffer2, int start2, int end2) { if (end1 - start1 != end2 - start2) return false; for (int i = start1; i < end1; i++) { if (buffer1[i] != buffer2[i - start1 + start2]) return false; } return true; }