boolean (@NotNull CharSequence text, int startIndex, @NotNull CharSequence prefix) { int tl = text.length(); if (startIndex < 0 || startIndex > tl) { throw new IllegalArgumentException("Index is out of bounds: " + startIndex + ", length: " + tl); } int l1 = tl - startIndex; int l2 = prefix.length(); if (l1 < l2) return false; for (int i = 0; i < l2; i++) { if (text.charAt(i + startIndex) != prefix.charAt(i)) return false; } return true; }