I used the example from the last task, but for some reason the last requirement is not satisfied, and i can't see where is the mistake.
package com.codegym.task.task07.task0709;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
Expressing ourselves more concisely
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<String> strings = new ArrayList<String>();
for(int i = 0; i < 5; i++) {
strings.add(reader.readLine());
}
String s = strings.get(0);
for(int i = 0; i < strings.size(); i++) {
if(strings.get(i).length() < s.length()) {
s = strings.get(i);
}
}
for(int i = 0; i < strings.size(); i++) {
if(strings.get(i).length() == s.length()) {
System.out.println(strings.get(i));
}
else {
System.out.println();
}
}
}
}