подскажите почему не проходит, выводит как надо
package com.javarush.task.task22.task2202;
/*
Найти подстроку
*/
public class Solution {
public static void main(String[] args) {
System.out.println(getPartOfString("Амиго и Д"));
}
public static String getPartOfString(String string) {
try {
String s1 = null;
String s2 = null;
String[] strings = string.split("");
for (int i = 0; i < strings.length; i++) {
if (strings[i].equals(" ")) {
s1 = string.substring(i + 1);
break;
}
}
String[] s = s1.split("");
String[] s3 = string.split(" ");
int inte = 0;
for (int i = 0; i < s.length; i++) {
if (s[i].equals(" ")) {
inte++;
}
if (inte == 3) {
s2 = s1.substring(0, i + 1 + s3[4].length());
break;
}
if (s2 == null) {
throw new TooShortStringException();
}
}
return s2;
} catch (Exception e) {
throw new TooShortStringException();
}
}
public static class TooShortStringException extends RuntimeException {
}
}