Всем привет, не пойму, почему не проходит валидацию. Вывод вроде бы правильный
package com.javarush.task.task22.task2202;
/*
Найти подстроку
*/
import java.util.ArrayList;
import java.util.List;
public class Solution {
public static void main(String[] args) {
System.out.println(getPartOfString("JavaRush - лучший сервис обучения Java."));
}
public static String getPartOfString(String string) {
int counter = 0;
int index = 0;
int till = 0;
char[] str = string.toCharArray();
for (int i = 0; i < str.length; i++){
if (Character.isWhitespace(str[i])){
counter++;
}
if ((Character.isWhitespace(str[i]))& (counter == 1)){
index = i;
}
if ((Character.isWhitespace(str[i]))& (counter == 5)){
till = i;
}
}
if (counter<5){
throw new TooShortStringException();
}
return string.substring(index,till);
}
public static class TooShortStringException extends RuntimeException {
}
}