class Encoder {

    public static String substring(String tail, int startIndex, int endIndex) {
        if (tail == null) {
            return "";
        }
        if (tail.length() <= startIndex) {
            return "";
        } else {
            if (endIndex > tail.length() - 1) {
                return tail.substring(startIndex, tail.length());
            } else {
                return tail.substring(startIndex, endIndex);
            }
        }
    }

}

class EncoderTest {

    @Test
    public void testSubstringEndIndexEqualsToStartIndex() throws Exception {

        Encoder encoder = new Encoder();
        String result = encoder.substring("ERT", 2, 2);
        Assertions.assertThat(result).isEqualTo("");
    }

}