code: public static boolean substringEquals(final String s1,
              final int fromIndex1, final int toIndex1,
              final String s2, final int fromIndex2, final int toIndex2) {
  
          if (toIndex1 < fromIndex1) {
              throw new IndexOutOfBoundsException();
          }
          if (toIndex2 < fromIndex2) {
              throw new IndexOutOfBoundsException();
          }
  
          final int len1 = toIndex1 - fromIndex1;
          final int len2 = toIndex2 - fromIndex2;
          if (len1 != len2) {
              return false;
          }
  
          for (int i = 0; i < len1; ++i) {
              if (s1.charAt(fromIndex1 + i) != s2.charAt(fromIndex2 + i)) {
                  return false;
              }
          }
  
          return true;
      }
docs: Check equality of two substrings. This method does not create
  intermediate {@link String} objects and is roughly equivalent to:
  
  <pre>
  <code>
  String sub1 = s1.substring(fromIndex1, toIndex1);
  String sub2 = s2.substring(fromIndex2, toIndex2);
  sub1.equals(sub2);
  </code>
  </pre>
  
  @param s1 First string
  @param fromIndex1 Starting index within {@code s1}
  @param toIndex1 Ending index within {@code s1}
  @param s2 Second string
  @param fromIndex2 Starting index within {@code s2}
  @param toIndex2 Ending index within {@code s2}
  @return {@code boolean}