Wcześniejsze zadanie zrobiłem analogicznie ze znajdowaniem max ciągu i działa dobrze a to nie.
package pl.codegym.task.task07.task0709;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
/*
Mów zwięźle
*/
public class Solution {
//private static Lista<String> strings;
public static void main(String[] args) throws Exception {
ArrayList<String> lista = new ArrayList<String>();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
for (int i = 0; i < 5; i++) {
lista.add(reader.readLine());
}
String min = lista.get(0);
for (String element : lista) {
if (element.length() < min.length()) {
min = element;
}
}
for (String element : lista) {
if (element.length() == min.length()) ;
System.out.println(element);
}
}
}