int (@NotNull String s1, @NotNull String s2, int offset1, int offset2, int end1) { for (int i = offset1, j = offset2; i < end1; i++, j++) { final int diff = s1.charAt(i) - s2.charAt(j); if (diff != 0) return diff; } return 0; }